I'd say in the majority of defensive situations a handgun is the best tool. Some have been mentioned already, and my rational has as well, the handgun is the tool you wear, not carry, you can have it on you at nearly any time, fairly conveniently, even while working or doing other things than getting ready for an assault. Most situations develop from uncertain beginnings, carrying a long gun around where most problems occur just isn't practical or realistic, not is it generally realistic for non-law officers to present an arm before knowing things are going south. Handguns are discrete enough to appear non threatening or totally unnoticed until things go wrong, then are instantly available for use.
I've often heard the saying that a handgun is to fight your way to your rifle, but think that's pretty far fetched in most instances. Having any long gun close by in day to day life isnt practical, even living out in rural areas. If you can get to a long gun by using a handgun, you could well get clear of the problem as well. I'd suggest using the handgun to deal with the problem straight away. I think the mindset of always trying to get to a long gun, which may be nowhere close, is unrealistic in most instances. If it's availalbe, sure, get it, but even where I am (very rural mountain area), having a long gun close at hand at all times isn't very practical. I always have a handgun, they are easy to have available.
Hitting at distance with a handgun isn't that tough, it takes some practice. Most try it once or twice, or never, and give up, defeating themselves before even getting a clue how to do it. It forces you to focus on the basics, but isn't that difficult once it's understood. I don't even think of shotguns in a defensive role, just handguns and rifles. Whatever I could do with a shotgun, even a very good one, I could do better with a rifle. I don't know how far a smoothbore shotgun can hit well, but I'd guess I could hit at least as well with a decent handgun, if not to farther ranges. I'm not speculating on distance shooting with a handgun, I've done it fairly often for 25 years. It just isn't that hard to do once you get started. There may be places that a shotgun is a good tool, but the wide open spaces of the west isnt it. YMMV, that's my perspective.
"Far better it is to dare mighty things, to win glorious triumphs even though checkered by failure, than to rank with those poor spirits who neither enjoy nor suffer much because they live in the gray twilight that knows neither victory nor defeat." -Theodore Roosevelt-