You should stop pedalling right after you feel that the bike chain has fallen off. If you keep on pedalling, it may cause the chain to jam between the sprockets and the frame of the bike. Stop the bike and get off from it.
If you see the chain jammed between the sprocket and the frame, free it using your hands. Here, you should completely forget about keeping your hands clean.
If the chain has fallen off from the front sprocket, then lay a small portion of the chain on top of it. You do not need to wrap the whole chain over the sprocket, as it may not be possible because of the tension in the chain.
Raise the rear wheel and rotate it. You can also rotate the pedals or even run the bike with hands. As a result, the chain will automatically fall into place.
If you find the chain falling off again, you can then adjust the position of the front shift lever and repeat the same process again.
If the chain remains at its place but creates continuous clicking sound, then you may need to reposition the front shift lever again, until the sound disappears.
If the chain falls off from the rear sprocket, then you will have to repeat the same process which you learned about fixing the chain on front sprocket. However, it can become a bit difficult if you have multiple sprockets installed at the back wheel and you find the chain stuck between two sprockets. You will have to take the chain out and fix the jam, before making the chain to fell into place on the sprocket.