Most dreams occur during the REM stage of the sleep cycle. REM stands for "rapid eye movement" referring to the rapid movement of the eyes during this stage of sleep. Sometimes when we wake up, we'll still be in REM sleep, even though the dream is over. I think that is what you experienced.