It happens to solo and mutual masturbators, to:
When you get a sad or irritable feeling after consensual sex, you may have postcoital dysphoria (PCD). This is commonly referred to as “post-sex blues.” This happens when you feel a range of negative feelings after desired sexual activity. You can feel a range of emotions including sadness, irritability, agitation, anxiety, and depression after sex with a partner.
Source: What Causes Sadness After Sex? The Impact of Mental Health
The solution is to avoid having sex.