Within the human mind, there’s a hierarchy of responses one takes against a possible threat. Way back when, that was basically summed up with “fight” or “flight,” responsible built into our biology. As mankind began creating societies, which means laws, some things eventually changed. We added some suggestions to the hierarchy for use at different points.
One of those is the restraining order.
When someone is feeling threatened, they have the option of having a court declare that the threatening individual must remain a certain distance away. Failure to do so will lead to the individual being arrested.