Sounds like a hypnic jerk to me, as Apopholis and Shift stated. Happens to me all the time, really.

Once I had just about fallen asleep in the car, when my whole body jerked violently and I slammed my hand against the window very painfully. Scared my parents to death; they thought I'd done it on purpose untill I explained what had happened.