For bear defense, I don't know if I would trust my life to a 40 S&W. For one, a lot of the hot loads for the 40 (Plus P heavy loads) may give you problems in a stock pistol (looking at you Glock). But I also would not go with the 10MM for bear country either. I subscribe to the 44 magnum is the minimum handgun caliber for bear defense.Another thing one can do is get the best ammo for a gun you already own, like a 40 S&W, rather than buying that new 10mm. There are some deep penetration options with ammo & bullets for handloading from Underwood, Lehigh Defense, & others. I’m kinda thinking, some of the very best options for the 40, can outperform many average ammo types used in the 10mm.
Now, if not in brown bear country, the other calibre's would most likely be just fine for any wildlife encounters, I would just remember that if your having a black bear encounter, most of the time that is a predatory encounter and very dangerous, so you may wanna make sure you have enough gun there as well.
I kind of have a.... East coast/mid west wilderness...pretty much anything other than a 22 will take care of any issues you may have.
Mountain and West....start with 44 mag and go up from there. 44 mag and shotgun make a pretty good bear defense combo, and versatile pretty much anywhere you go.
Alaska...454 casull, shotgun, Rifle (375 H&H/ 45/70