The medical term is hypnopompia
Hypnagogia is the transitional state of consciousness between wakefulness and sleep. It’s the opposite of hypnopompia, which is the transitional state that occurs before you wake up. (Healthline)
Wikipedia explains:
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.
And about the dreaming, sleepfoundation says that:
During hypnopompic hallucinations, you are sensing things that are not actually happening while in a state between dreaming and waking.