off the rails
In an abnormal or malfunctioning condition, as in Her political campaign has been off the rails for months. The phrase occurs commonly with go, as in Once the superintendent resigned, the effort to reform the school system went off the rails. This idiom alludes to the rails on which trains run; if a train goes off the rails, it stops or crashes. [Mid-1800s]