A bunch of factors outweigh power...
... those factors have something in common - they affect the ability to score fast, reliable hits.
If you are not a reloader, .40 will cost less than .45, and 9mm will cost less than either, so it's financially easier to practice more with a 9mm than with a .40, and with a .40 than with a .45. More practice = more hits.
Even if you are a reloader, small primers, lighter bullets, and less powder = lower cost for the 9mm, with the .40 more expensive, and the .45 even more expensive. Tolerances are tighter on the .40, though, due to pressure levels.
Practice makes a big difference as far as getting good hits goes; practice also helps one determine the real world reliability of one's choice of weapons and ammunition (with regard to reliable cycling and feeding).
For some people, the snappier recoil of .40, or the pushier recoil of the .45, will make those rounds slower to shoot than the 9mm (longer recovery time between shots). If raw power were king, more people would use the .44 magnum, or .460 or .500 S&W for defensive pistols. Those rounds are very expensive, and their recoils are high and punishing, so shooters probably won't practice much with them; even with practice, follow-up shots are not normally fast. (Though I have seen a couple shooters who can unload a S&W 29 pretty quickly and accurately.)
While I like .45s, and several of my carry guns are .45s, I don't shoot them as quickly as I can shoot my 9mm pistols. I haven't done a time comparison with .40s, but from watching friends who shoot all three calibers in competition, given similar platforms, 9mm allows faster recovery than does .40, and .40 allows faster recovery than does .45.
If I had to carry a single shot pistol, I'd probably go with a .45.
If I want a compact, easily concealed pistol that I can still shoot quickly and accurately, then it is going to be a 9mm.
I own a .40, and like it well enough, but it's almost never my carry weapon.