When you dream you're in REM sleep (rapid eye movement). REM sleep is only slightly more "deep" than stage 1 of non-REM which means it's not that hard to wake you up in the first place.
Dying in a dream is a stressful event, which causes your brain to release adrenaline. You can't sleep and have an adrenaline rush at the same time so you wake up.
These dreams where you die and wake up are usually more memorable due to the fact that you wake up whereas most people don't remember 95% of their dreams.
"Being particularly scary or threatening, nightmares can provoke ‘fight and flight’ responses, and the release of adrenalin whilst we are still asleep. Once you awaken from a nightmare it may then take a little time to come down from this elevated state, preventing you from being able to get back to sleep as easily or quickly."
Profeso Colin Espie, Director of the Sleep Centre at the University of Glasgow and co-founder of Sleepio
"We forget almost all dreams soon after waking up. Our forgetfulness is generally attributed to neurochemical conditions in the brain that occur during REM sleep, a phase of sleep characterized by rapid eye movements and dreaming. But that may not be the whole story.
Perhaps the most compelling explanation is the absence of the hormone norepinephrine in the cerebral cortex, a brain region that plays a key role in memory, thought, language and consciousness. A study published in 2002 in the American Journal of Psychiatry supports the theory that the presence of norepinephrine enhances memory in humans, although its role in learning and recall remains controversial."
"At least 95% of all dreams are not remembered. Certain brain chemicals necessary for converting short-term memories into long-term ones are suppressed during REM sleep. Unless a dream is particularly vivid and if one wakes during or immediately after it, the content of the dream is not remembered"
Hobson, J.A.; McCarly, R.W. (1977). "The brain as a dream-state generator: An activation-synthesis hypothesis of the dream process". American Journal of Psychiatry 134 (12): 1335–1348.