It takes practice and self discipline. But I had the same problem and had to teach myself to stop my mind from running on the wheel all night long.
Number 1..... Turn the clock so you don't see the time each time your eyes drift in that direction. Leave it where you can see the time if you need to, but it should take some effort, like sitting up and turning it to see it.
Number 2 ....... Lie in your most comfortable position, and pick a point on the wall to stare at. Stay focused on it as much as you can. If your eyes close, let them, but if they start to wander, bring them back to that focal point.
Number 3 ...... Start counting backwards from 1000 while staring at that spot on the wall. If your mind drifts and your thoughts intrude, as soon as you notice it is happening, stop and start counting back from the last number you remember thinking. The first couple of nights, this is really hard to do, but if you stick with it, it becomes very easy. The reason for counting backwards is because it forces you to concentrate on the counting. Counting forwards is too easy and you can do it without really concentrating.
It's kind of a self hypnosis thing without all the mumbo jumbo.
Call it meditation if you like.
No matter what you call it, it works.
Good luck. Try it or don't, but I hope you find a way to get some peaceful sleep.