Your body, in falling asleep, is switching from conscious control to the autonomic nervous system, to maintain "life support" during the night. If there is any problem with this changeover then it will "abort" the switchover using that jolt, then try again.