Answer: The right answer is "just before it left the station."
Explanation: Just to elaborate further on the answer, it can also be added that the other three options are incorrect and do not make sense. If they caught the train it does not make sense to say that it was because they liked driving to work, so that option should be discarded. In addition, if they ran swiftly in order to catch the train it does not make sense to add that they did it in order to arrive at work late - just the opposite. Finally, if, by running swiftly, they were able to catch the train, it could not have already left the station. Therefore, the only valid option is "just before it left the station."