Digression
Derailment
noun, verbal noun
When you're trying to escape from the line, you're trying to make a digression. I mean, that's basically what a digression is—an escape from the main line of thought.
In a completely different context, this word is also used to refer to train (and other sorts of) derailments. Try to keep that one in the back of your mind.
This is a jukugo word, which usually means on'yomi readings from the kanji. If you know the readings of your kanji you'll know how to read this as well.
話が脱線しました。
I digressed from the subject.
電車が脱線しましたが、怪我人はありませんでした。
The train was derailed, but nobody was injured.
その電車は、運転手のとっさの判断で、脱線をまぬがれました。
The train was able to avoid derailment because of the driver's quick decision.