off the rails

(be /go /run) off the rails {infml} (to start behaving strangely or in a way that is not acceptable to society; to be spoiled by bad management; to be in an abnormal or malfunctioning condition) —

1. сбиться с (правильного) пути, сбиться с пути истинного, пойти по неверной дорожке; свернуть на опасную тропинку

Example: He went off the rails in his twenties and started living on the streets. (thefreedictionary.com)

Example: By the law of probabilities if you have five kids, one of them's going to go off the rails. (thefreedictionary.com)

2. пойти неперекосяк; пойти вкривь и вкось; пойти из рук вон плохо, разладиться

Example: Things were going off the rails here, and no one was getting any work done. (thefreedictionary.com)

Example: This is a well-intentioned system that has been run off the rails. (thefreedictionary.com)

Example: Her political campaign has been off the rails for months. (The American Heritage Dictionary of Idioms)

Example: Once the superintendent resigned, the effort to reform the school system went off the rails. (The American Heritage Dictionary of Idioms)

3. быть выбитым из колеи, дезориентированным; не в своём уме, не в себе; ~ (у кого-л.), не все дома

Example: ...

This idiom alludes to the rails (metal bars) on which trains run; if a train goes off the rails (lit. сходит с рельсов), it stops or crashes.