Srimad Bhagavatam Canto 08, Chapter 12, Text 35

SB 8.12.35

skanne retasi so ’pasyad
 atmanam deva-mayaya
jadikrtam nrpa-srestha
 sannyavartata kasmalat
 
Translation by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
O Maharaja Pariksit, best of kings, when Lord Siva had fully discharged semen, he could see how he himself had been victimized by the illusion created by the Supreme Personality of Godhead. Thus he restrained himself from any further maya.
 
Purport by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
Once one is agitated by lusty desires upon seeing a woman, those desires increase more and more, but when semen is discharged in the act of sex, the lusty desires diminish. The same principle acted upon Lord Siva. He was allured by the beautiful woman Mohini-murti, but when his semen had been fully discharged, he came to his senses and realized how he had been victimized as soon as he saw the woman in the forest. If one is trained to protect his semen by observing celibacy, naturally he is not attracted by the beauty of a woman. If one can remain a brahmacari, he saves himself so much trouble in material existence. Material existence means enjoying the pleasure of sexual intercourse (yan maithunadi-grhamedhi-sukham). If one is educated about sex life and is trained to protect his semen, he is saved from the danger of material existence.
Srimad Bhagavatam Canto 08, Chapter 12, Text 34
Srimad Bhagavatam Canto 08, Chapter 12, Text 36