Sexual activity can often contribute to better sleep. After an orgasm, the body releases hormones like oxytocin and prolactin, that can induce pleasant and relaxing feelings. Sex also reduces levels of the hormone cortisol, which is associated with stress.
Studies indicate that these hormonal changes can cause drowsiness and make it easier to fall asleep. This effect can occur with masturbation as well as sex. Around 50% of both men and women say that an orgasm from masturbation helps them fall asleep and improves their sleep quality.
Sex with a partner may enhance this hormonal response and facilitate greater feelings of closeness and intimacy that are conducive to sleep. In heterosexual partners, research has found this effect to be greater in men than women, which aligns with a popular social conception of men quickly falling asleep after sex.