I want to describe a train which is going out of rails. In Farsi/Persian language we say an "out of line train" but I am not sure about English. I found something about out of rails not out of line or lines. Also, there is a doubt that can I use it for broken trains too which are not in use anymore?
If I'm understanding you correctly, you are referring to a train that is being removed from service, and not to a train that has derailed from the tracks. If I'm right about that, then the word decommissioned might apply:
decommission (v.) to stop using something such as a weapon, ship, or nuclear power station (Macmillan)
If you are instead referring to a train that is off the tracks (due to a mechanical malfunction), you would say the train has derailed, or is off the tracks, or is off the rails, although that last expression is also a euphemism for "going insane", much like off his rocker. As Ozzy Ozbourne sang: "I'm going off the rails on a crazy train!"