Hypnopompia
Hypnopompia (also known as hypnopompic state) is the state of consciousness leading out of sleep, a term coined by the psychical researcher Frederic Myers. Its mirror is the hypnagogic state at sleep onset; though often conflated, the two states are not identical and have a different phenomenological character. Hypnopompic and hypnagogic hallucinations are frequently accompanied by sleep paralysis, which is a state wherein one is consciously aware of one's surroundings but unable to move or speak.

Hallucinations
Hallucinations are commonly understood as "sensory perceptions that occur in the absence of an objective stimulus". As this definition implies, though, like dreams, most hallucinations are visual, they can encompass a broader range of sensory experience. Auditory hallucinations are thus also common: "patients can hear simple sounds, structured melodies or complete sentences". Slightly less common but not unheard of are "somesthetic" hallucinations involving the sense of touch and location, with such experiences ranging from tactile sensations to full-blown "cenesthopathic" or "out-of-body experiences", which involve sudden changes in the perception of the body’s location, or even a sense of movement of the entire body. Finally, a unique characteristic of hypnopompic hallucinations is that as opposed to dreams, wherein they rarely understand that they are asleep, here sleepers do indeed have "the clear subjective awareness of being awake" yet are frequently mentally and physically trapped in the experience.

Neurobiology
The objective difference between the subjective experiences of dreams and hypnopompic hallucinations emerges from a close look at the sleep cycle and its attendant brain activity: there are essentially two types of sleep, R.E.M. sleep, which is indeed categorized by "rapid eye movement" and N.R.E.M., which stands for "Non-Rapid Eye Movement". In R.E.M. sleep, brains are extremely active. In particular, during this stage, both the brain-stem, which is the home of the most fundamental physical drives, and the parts of the cortex related to the most complex logical-cognitive functions experience highly intense electrical activity. Thus, R.E.M. is where the majority of dreaming occurs - it has been all but confirmed at this point that dreams originate in the brain-stem, a spark from there driving the more logical mind to contemplate and consolidate, through dreaming, memories that relate to fulfilling fundamental drives. Conversely, there is almost no electrical activity during N.R.E.M. sleep. N.R.E.M. is what is referred to as "deep sleep", which is characterized by the complete quieting of the mind, to include dreamlessness, and by muscle "atonia", which is to say paralysis, a complete motor disconnect. A last critical point in this regard is that R.E.M. sleep cycles are book-ended by N.R.E.M. stages.It is precisely at this last point, though, that a quirk in brain chemistry, can cause hypnopompic hallucinations: occasionally during deep N.R.E.M., "transient patterns of neural activation in brainstem structures [resembling] micro-wake "fragments" can occur". These have a two-fold effect: first, just as in R.E.M. sleep, these brain-stem fragments essentially activate the dream mechanism. Second, they catalyze a near-waking state. However, this is often not powerful enough to jar a person completely out of deep sleep, and so only the mind fully awakens, leaving the body trapped in the atonia of deep sleep. Another reason why hypnopompic hallucinations are often such horrible experiences is that micro-wake fragments appear to be related to serotonin and dopamine deficits—these deficits predispose a person to negative mental states, which likely causes the hallucinations to resemble bad dreams.

Cultural manifestations
These mental experiences are indeed often deeply damaging: across cultures, the experience of hypnopompic hallucinations are strongly related to "visitations of spirits, demons or other grotesque creatures belonging to traditional folklore". Thus, in the Anglosphere, hypnopompic experiences often entail the sense that an "Old Hag" or some similar "nocturnal spirit" is sitting on the sleeper’s chest, inducing both paralysis and an increasing, suffocating inability to move. Anthropologists have discovered references dating back to the High Middle ages of similar figures in Anglo-Saxon and Anglo-Norman traditions, most prominently the "mæra", the source of the word "nightmare", and which appears to have roots in ancient Germanic superstitions.
Similarly, subjects belonging to Yoruban-African diasporas report feeling as though they are being "ridden" by the evil manifestations of their versions of the African pantheon (ridden is the vernacular for possession by the gods, who are often referred to as "divine horsemen"). Some members of the Yoruba diaspora appear to conflate the cultural interpretation of the experience, referring to "being ridden by the witch". Japanese interpretations of the experience are often grouped under the heading of kanashibari, a term which literally means "bound in gold or metal" and derives from the name of an esoteric Buddhist technique for paralyzing enemies.

Future research horizons
Owing to similarities between hypnopompic hallucinations and those experienced by people with dementia, Parkinson’s and schizophrenia, significant progress is being made on understanding the neurobiological basis of this experience. Researchers have identified "a common neurofunctional substrate [which] points to a shared pattern of brain activation" underlying elements of schizophrenic delusions and these near-waking hallucinations: "with regional grey matter blood flow values being maximally increased in right parietal-occipital regions" during hypnagogic hallucinations and many schizoid episodes. Thus, such painful near-waking experiences could be rendered obsolete.

See also
False awakening
Lucid dream

Notes
References
T. Balkin, A. Braun, et al., "The process of awakening: A PET study of regional brain activity patterns mediating the reestablishment of alertness and consciousness," Brain, vol. 125, 2002, pp. 2308–19.
P. Tassi and A. Muzet, "Sleep inertia," Sleep Medicine Review, vol. 4, no. 4, 2000, pp. 341–53.
Warren, Jeff (2007). "The Hypnopompic". The Head Trip: Adventures on the Wheel of Consciousness. ISBN 978-0-679-31408-0.