The immediate question is, why wasn't the gun already loaded? Those actions and lost time could have cost you, well, more than you wanted. So, if you're going to use a gun for defense, keep it loaded.
We can talk about the choice of tool, handgun vs shotgun vs rifle vs Claymore, another time. In this case I really think the caliber is irrelevant. But here is what I would have picked; .45ACP. Why? Because I shoot it best. Yes, I can hit what I aim at with all of them, but if I'm best with the .45 when I'm not stressed, that's the one I can Guarantee the hit with when I am stressed.
Let's drift this just a little and talk about what you did right...
You didn't go searching. All too often people leave the relative safety of their barricaded position, inside the house, and go searching for the potential bad guy. This puts you at a significant disadvantage because then all they have to do is wait for you to come by and they get the jump on you. So, good for you to stay put.
You turned the lights off inside. This does two things for you; it alerts any potential bad guy that you're aware of them and it hides you from their vision.
You had motion activated lights outside. If there really was a bad guy, they would have been lit up and you would have been in the dark. This is a significant advantage for you. The one thing I would add to this security feature is the ability to manually turn them on from inside. This way you can light anything outside, moving or not. Again, this is an advantage for you and likely would end any encounter, animal or human, before it starts.
With the exception of the gun not being loaded already, you had a good action plan.