I say this one a lot. Google search didn't give me results for how the phrase came into being but when a train goes off the rails it generally leads to destruction of some kind. Similarly when a person goes off the rails there is usually destruction of some kind.