The driver, who’s car had become stuck on the tracks, was pulled out of the way just in time