Kudos for your swift reaction. You did absolutely the right thing. Way to trust those instincts!
There is a lot of crime in my old college town (Providence, RI), which for it's size is appalling. Luckily, I was never mugged (but scores of students are every year), and I only had to brandish my EDC knife once to a guy who was repeatedly "asking" to come into my room from the ground-level window. I yelled at him and called campus security as well, but you can be damn sure I was ready to fight back if I had to, even though I was really scared.
The kids at school, they never ran away or fought back during a mugging. Acquiesing to any of the demands of the criminal is, in my mind, an invitation for worse (and as a woman I stand to lose a lot by giving up). I guess the fear made them freeze. You did well by taking that adrenaline and running away. I can only hope that if faced with that situation, I can do the same thing.