Demons can still function fully well with their head or other body parts detached, and they move in response to the mind normally. Only sunlight and Nichirin metal can do permanent damage to them due to disintegration. Wisteria flowers are also toxic to them ,which is how Shinobu gets away with stabbing instead of decapitating. However, the time taken for a demon to fully disintegrate outside of sunlight depends on the strength of the demon. In the anime, all of the moon demons get conveniently juuuuuusssst enough time to express their final thoughts and run through an emotional flashback scene. The upper moon demons can survive decapitation for some time and some have backup defenses and weakspots in other places, but in Douma's case, it's just his power that allows him to hold off the disintegration for as long as he does. Also, the part where Shinobu holds his head is after he died in a sort of hallucination.