Oh, just realize how it could be done.
The train would look for a brick x position down, left and right, and get that bricks object # and record them in a "Lasttrack" variable. Then, if the train cannot find a track to be aligned with, it will try to re-align itself! Also a "lastdirection" variable.
make it come to a complete halt, give warnings, etc.
So a train hitting a player will make the train stop, what?!