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!).
If you are alone have an older manual car you could 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 - but this method won't work in modern cars with starter buttons or where the clutch has to be pressed to start the engine.
You might be able to push the car clear, but remember the advice above:If there is any sign of a train approaching, leave the car and join your passengers (run!).
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!
Watch this through to see what happens when a train hits a car (about three minutes into the clip). Keep well clear if your car breaks down!