For me, it depends on the platform. Both are fine options for self-defense if you can hit what you are shooting at. If the gun is a smooth, easy shooter, I typically take the .40. As long as the gun I'm shooting has easy felt recoil (like my USP or Baby Eagle for examples), then I take the extra punch in the .40. If it is a platform that is small, polymer, and full of punch, I'll take the 9mm. The .40 in a tiny gun is really going to increase my follow-up shot time, and, in my personal experience, a couple or three rapid hits from either bullet will more than do the job. So, in small, light-weight platforms, I go 9mm.
***The only exception to this is, for me, is the XDm. I love the way the 9mm feels in that platform... and who can resist 20 shots?
***