Assuming that the car is a standard, you should first fully push in the clutch and then slowly press down the pedal, or pull up the handle, of your emergency brake (depending on what type you have in your vehicle) until you slow down to a complete stop.
Simple, stay calm, put the gear selector in neutral, coast to the safest place you can find, stop the car, turn off the key. Have the car towed to a repair shop and don't drive it until it's fixed.
car starts but when i put it in gear it stop
Maybe car is in park.
Automatic or manual trans? What am I missing here? Explain! If it is stuck in 3rd gear then it is obvious that it can't go in reverse.
your car must be stuck in a low gear and not able to switch out
Turn the ignition off.
Bogged down or mired.
Gear shifting has little to do with batteries, or your car's electrical system. If your car is stuck in one gear, your clutch (on a manual) or even worse, your transmission, might be going out. The dead battery might be just a coincidence.
Consult online forums for your car. If that doesn't help try and play about with the gear selector the see if it will budge.
It is being put in to limp in mode. The computer has detected a problem, get it checked out with a scanner
If your car is stuck on the tracks, and a train is approaching- then YES- get OUT of the car and get off the tracks. It is not that the train engineer does not want to stop, it is that he CANNOT stop- it may take a mile or more in distance to fully stop a heavy train. You will lose the car, but you will keep your life.
Your car engine will stop.