I go through the same thing as you every night, it's so frustrating. Try not to think about things and try and keep still, try not to take in too much caffeine also.
It's difficult, though, at times I will just lie down in bed until 2-3 thinking about girls.