The explosion you see in the gondola was the track charge - the point where the engines were "supposed" to come together. Engines running themselves don't play by the rules. They had explosive charges under the running boards and in the track at the anticipated hit point. They really wanted to be sure they got a good blow up. Couldn't repeat the scene. They had a whole bunch of cameras rolling on the shot.
There was a great write up on the process in the original dedication booklet of the Knott's Berry Farm narrow gauge operation from the early '50s. Opening of the park's train ride happened right after the release of the movie and some of the principle stars, Sterling Hayden and Laura Elliot, were there to drive the golden spike. The 41 was painted to match the 268 in the movie and ran that way for a season or two.