I suffer from insomnia. Last night I went to bed at 10pm and woke up at 1:30am. I never got back to sleep.
I usually indulge in non-sexual fantasies. If you are a musician, imagine playing in front of a packed stadium. Like guns? Imagine being a commando. You get the idea. It distracts the mind long enough to slow down and stop thinking of what went on today and what is going to happen tomorrow.