It is good general advice to not play a game right up until bedtime. Some people can, and still sleep well, but it effects most people.
Some of my favourite games like 4X genre (just one more turn!), XCOM and the Mount & Blade formula hook you into keeping playing a given session by filling the possibility space of your mind. You've got ideas racing in your head and you don't want to forget them, but when you act them out to relieve that psychological tension, the game masterfully lays out more bread crumbs so that your mind fills with more ideas... the next thing you know its 3 in the morning.
If you find it difficult to get up from the game to go to bed, or just need help walking away from it sooner in the evening so you can clear it from you mind and do something else before bed, write down all the things you want to get done before you log out. Once they are written down you won't be scared that you're going to forget them, and you can actually log out without doing them. Better still, because you haven't done them and been presented with breadcrumbs to stimulate the next idea about what to do, you break the cycle and it helps free you from the game until the next time you choose to sit down to play.
Play the game. Don't let the game play you.