The cholinergic neurons in the basal forebrain release acetylcholine onto neocortical neurons to stimulate the beta rhythm of electroencephalogram (EEG). The midbrain contains serotonergic neurons, which stimulate neocortical cells, which produce beta rhythm.
The cholinergic EEG shows waking during still alert conditions, while the serotonergic EEG shows waking during movement.
As the neural systems are separate for making us awake during still and moving conditions, moving awakens when we sleep at an inconvenient time.