Stop, Look, Listen. But what does that really mean?
Stop is self explanatory, but I'll add this; Stop back as far as possible, with a minimum of 50 feet, whenever practical. Keep in mind a derailment can happen any place at any time. Give yourself some room, unless being killed in a freak accident is on your list of things to do today. Hedge your bet and increase the odds of survival.
Look, means a real look, not just a glance. Rarely do people take into account that locomotives also shove cars around, not always pulling them. If you glance down the track and see the end of a boxcar, unless you really pay attention, it is easy to assume the train is going away from you. You'd be dead wrong.
Listen means really listen, by turning off the music and rolling down the window, rain or shine.
In addition, these life saving steps should be taken at every crossing, whether that crossing is protected by electromechanical means (gates, lights, bells) or a rural, unprotected crossing. People are probably sick of me saying it, but even though there is battery back-up for protection in the event power failure, there are other conditions that can present themselves that will render such protection inoperative.
This advice is especially important when traveling in inclement weather. If it's snowing, it is likely the locomotive's whistle is plugged up, so don't count on hearing a train's approach.
A very good safety question and those always rate a star.