It can sometimes take over an hour for me to fall asleep, so I've developed some strict rules.
About an hour before bed, I'll set my alarm on my phone, have a big glass of water, and then cut off all screen usage. No internet, no TV, no phone, nothing. I also avoid eating or doing strenuous activity. If I was just looking at a screen, I'll take a nice, slow walk. If the weather isn't conducive to that, I'll do some easy stretches and yoga poses. I used to listen to music as well, but I've found that some good old peace & quiet is better for helping me wind down. Afterwards, I brush my teeth, take a piss, and head to bed.
One thing that helps tremendously is f.lux. It's a program that slightly changes the hue and brightness of your computer screen depending on the time of day. It's seriously magnificent!