Self defense.
You have a legal obligation to retreat at every opportunity. Self defense is only valid if you've exhausted every possible avenue of retreat.
This is to prevent the propagation of violence, and it's effective, and it's how self defense laws are in all civilized countries.