Breakdown at a railway crossing
Firstly, never stop on a crossing. If there is a traffic queue, wait for the cars beyond the crossing to move so that you have a clear exit.
If you do break down or stall (and the car won't immediately restart), get all of your passengers out immediately and well clear off the crossing (at least 50 metres).
Note: The best way to go is probably towards the train - that way if a train does hit your car any impact will scatter debris away from you and the train will shield you.
Next, inform the signalman by using the track side telephone. If there is no telephone, call the emergency services. If there is any sign of a train approaching, leave the car and join your passengers (run!).
Try moving the car by engaging a gear (second is probably the best) and turning the starter motor... This might be enough to 'jerk' the wheels free of the tracks and move the vehicle to safety. This might damage your starter motor, but the alternative is shown in the video below... Alternatively, you might be able to push the car clear.
The same advice applies to breakdowns on tramways.
The Highway Code Rule 299 says:
Incidents and breakdowns. If your vehicle breaks down, or if you have an incident on a crossing you should:
• Get everyone out of the vehicle and clear of the crossing immediately
• Use a railway telephone if available to tell the signal operator. Follow the instructions you are given
• Move the vehicle clear of the crossing if there is time before a train arrives. If the alarm sounds, or the amber light comes on, leave the vehicle and get clear of the crossing immediately
Stay calm - stay safe!