Typically the travel limits are connected to the controller or drive. The hard stops should be strong enough to resist the torque of the motor. In the case of a servo motor, the drives normally have over-torque and/or encoder error protection built in and that should disable the drive. In the case of stepper motors, when they encounter excssive torque, they just magnetically decouple and stall without damage.
In the case of a run away motor, there is not much you can do besides hope that the hard stop holds up to the moving mass.