If it’s localized or focused on specific muscle groups in the body (even multiple muscle groups, but focused) and feels, for lack of better word, physical, then…it’s either a very extreme Hypopompic Jerk or a Hypnogogic Jerk (that is, when your body falls asleep or wakes up, but some muscles didn’t get the message of “all right, we’re all falling asleep now” at the same time as the other muscles, then they’re going to spasm.) Or it’s an actual seizure.
However, if it feels like the consequence of something else outside and all over, then it could in my experience be like the first part of an out-of-body experience. Unless at the same time there was an earthquake, well, earthquakes don’t usually feel like what they look like on television, they usually feel more like being on a boat with everything swaying rather than shaking.
So anyway, the first part of an out-of-body experience usually feels like you’re laid down at the backseat of a car that is driving over a bumpy road: your body is getting jolted around, but it’s not because of your own muscles.
If the lattermost is more like what it feels like, then what I advise is to gently move your awareness…don’t focus on it, because that can be “too sharp” a mental activity, but rather gently shift your attention to the air that’s in front of your face, and then the air that is in front of that layer of air. For me, out-of-body experiences have been very visual (which, if you think too much about it, doesn’t make much sense because I don’t have eyeballs if I’m out-of-body, but that’s been my experience that it’s been very visual,) and so eventually you might get the visual of the room that you fell asleep in except that everything is floaty. Some people say that their visual has something like a 360-degree fish-eye camera effect, others say that they only know where everything is but don’t see anything during an out-of-body experience.
And if you want it to stop, then usually bringing attention to your breathing and then trying to breathe harder than you are breathing naturally will do the trick. Others advise trying to move a finger or a toe on purpose, but I’ve found that to be too difficult during this sleep phase.
I hope this helps!