laws do vary from state to state.
But, as a practical matter, slow, look and listen. If possible stop (not usually an option) look and listen.
What that really means is, turn off the music for a a few seconds, roll down the window and listen.
But, you should always practice these tips for staying alive and in one piece at ALL railroad grade crossings, mechanical protection or no. The gates and bells are NOT fail-safe, contrary to popular opinion. Yes, they do have battery back up to protect against power failure, but they can fail for reasons other than a loss of electricity.
And, in a snow storm, the locomotive whistle can get clogged with snow and cease to operate. This is why you must also look. In addition, there are areas that are declared a "quiet zone," where the engineer is prohibited from using the whistle, save for emergency circumstances.
Grade crossing accidents as well as accidents involving pedestrians are 100% avoidable, but it is up to the motorist or pedestrian to do the protecting for themselves. A train will not come looking for you, but they have no qualms about killing you if you put yourself in their path.
All safety questions get a star from me. Here's yours. Thanks for asking.