I think there is some good advice here, I'm going to try and share my personal experience as well.
Back when I was in High School I used to work out a lot (Anaerobic mostly). Working out is extremely tiring so after a long day I usually had little problem getting to sleep. However, I was a teenager so there were still nights when I had insomnia. I quickly made the correlation between working out and being tired and came up with the brilliant idea: I'll work out right before bed so I'll sleep better.
Don't do this.
Turns out that is just about the worst idea in the world. A good workout is extremely stimulating; your heart starts pumping faster, body temperature rises, arteries contract and then dilate, none of which sounds like getting to bed. It turns out it also has a major effect on your brain. While we tend to not spend time thinking about moving around, on a neurological level its actually very engaging. We see activity in the hypocampus, increased bloodflow, burning of lactates, and the release of Epinephrine.
That last one is kind of important.
Epinephrine is one of those miracle drugs. It can restart your heart or give you super human strength. Its also the drug designed to be triggered in that flight or fight circumstance; evolutionarily, that's the one where you think you might die. Its not really a stretch to see how a hormone like Epinephrine can cause your body to stay away for prolonged periods of time
But Tzenes, why are you talking about workouts?
Well, a game that you really enjoy can have a very similar response to a work out. Your brain starts to get very active, has increased bloodflow, starts burning lactates, and starts releasing Epinephrine. Whoops.
I've actually talked about the connection between Epinephrine and Gaming before. Its most noticeable when your heart starts pounding or your fingers feel cold. Whether the game is immersive or its the competition that gets you going, its not hard to kick off that old flight or fight response; and once you do... good luck getting to bed.