The idiom "the light at the end of the tunnel" usually embodies a sense of hope or optimism, while "sometimes the light at the end of the tunnel is a moving train" does the opposite by implying that the light is not an endpoint, but a danger, like the like of a speeding train throttling toward a person. To reach safety, this light should be avoided.
"Sometimes the light at the end of the tunnel is a moving train" is a popular version of the idiom that describes something as "the light at the end of the tunnel." This refers to the end of a difficult time or task by comparing the oppressive darkness inside a tunnel to the brightness at the end when the task is completed. The light could be daylight, which would signal the end of the tunnel and safety ahead.
This phrase cautions against drawing a conclusion too quickly and ignoring warning signs. It is tempting to embrace anything that looks like the end to a challenge, but it is risky to make this decision too quickly. The phrase is attributed to American poet Robert Lowell, who wrote, "If we see a light at the end of the tunnel, it's the light of an oncoming train."