At a railroad crossing, a motorist:

When stopping at a railroad crossing, you must stop at least 15 feet from the nearest rail. Come to a complete stop if you can see a train or hear its whistle, if there is a stop sign, or if flashing lights, lowered gates, or a flagger indicate that a train is approaching. It is illegal to drive through, around, or under a lowered gate.
DMV Writen Test