You get a little bit more knockdown power with similar bullets out of the .40, you also get a more snappy recoil.
They both have their advantages, the 9mm will have easier follow-up shots due to less recoil. 9mm is a little bit cheaper to shoot than .40.
I think that with consideration paid to what you choose to keep it loaded with for defensive situations and proper shot placement are the most important things. With good shot placement and appropriate bullets, both have sufficient stopping power to neutralize a threat.