Sex and self-gratification has always helped me to sleep better, but at my lowest it was detrimental and would easily precipitate a crash. I have improved a little and use self-gratification to help me fall asleep sometimes with no ill effects.
The key here is to listen to your body. If you feel weak afterwards then don't do it. If it is helping you to get into deep sleep then I think that the sleep itself is worth it.