See this response:
http://gnosticteachings.org/forum/women,-hormones,-orgasm-and-children.html
The sexual spasm is prevented by using willpower, by remaining in chastity both mentally and emotionally, by breathing consciously, by using sacred mantras, by using prayer, and disconnecting well before it takes place.