I've had terrible insomnia my whole life, I really struggle to shut my brain down, and yes I often wake in the early hours and then can't get back to sleep.
I have managed to get it more under control, although I will say I work from home flexibly now, which has helped a lot because the stress of having to get up early for the office, and before that school, was too much. I was always shattered. I'm a night owl.
What works for me now is melatonin and magnesium every evening, about an hour before going to bed. Thankfully melatonin is non-subscription where I live. You can buy it in the supermarket.
I also take 50mg of trazodone, which knocks me right out, and doesn't build a tolerance or an addiction like the benzos and zopis. Occasionally, if I really need a good night's sleep, I'll take 100mg and also an antihistamine🤐
To shut my brain down I watch easy TV, or listen to podcasts or familiar audiobooks (Just William stories read by Martin Jarvis are the best). Sometimes just audio will not be enough to distract my brain, and I have to have the visual stimulation of TV as well, but I have the screen dimmed as low as possible, and on the warm tone setting.
If I wake up in the early hours, I put the podcasts or TV back on until my brain shuts down again. Doesn't always work, but it's better than it used to be.
Exercise is good, but only much earlier in the day. I do sleep much better when I'm in a good routine with exercise and doing at least an hour a day, but I am awful at sticking to routines. I tend to go in phases instead. It's very frustrating.