An empty chamber, bad guys with no shooting skills, and knowing when to stop shooting and get to safety. Some of it deals with training, some of it deals with luck, and some of it deals with being prepared to do your best in a deadly encounter.
The video below shows us all of that, and the honest thing is; this intended victim was damn lucky to walk away from this incident.