Nothing gets solved at three in the morning
"I'll just make myself stop"
Once you've seen that the thinking is the problem, the natural next move is to try to stop thinking. You lie there and order your mind to be quiet. "Stop it. Don't think about the roof. Think about nothing. Go to sleep."
You may already know how this goes. The roof comes back within seconds, often stronger. Trying to think of nothing turns out to be a task in itself, and an agitating one. And "go to sleep" is about the least effective instruction one can give oneself.
There are two separate problems here. One concerns thoughts and the other concerns sleep.
On thoughts, there's a long line of research showing that trying to suppress a thought tends to make it return. To check whether you're succeeding in not thinking about the roof, some part of your mind has to keep looking for the roof. So the effort of pushing the thought away is also what keeps it close at hand.
Allison Harvey and Suzanna Payne applied this to sleep. They gave 41 people with insomnia one of three instructions for a night. One group was told to distract themselves with a specific, engaging piece of imagery, which they'd chosen and elaborated in advance. One group was given a general instruction to distract themselves from their thoughts. One group got no instruction. The imagery group fell asleep faster than the group with no instruction, and their thoughts in bed were less frequent and less distressing. The researchers' explanation is that a rich, specific mental task occupies enough of the mind that worries don't get back in. They also note that it gives the mind something definite to look for, in place of something to avoid.
That's one small study, of a single night. But it fits the wider finding, and it points to something usable. You can't empty your mind by ordering it to be empty. You can give it something else to do, as long as the something else is absorbing, pleasant and has nothing to do with your life. Chapter 13 gives examples.
On sleep, the problem is that sleep isn't something you do. Colin Espie and colleagues have set this out in a theoretical paper. They argue that normal sleep is a largely automatic process. Because it's automatic, it's easily disrupted by focused attention and by direct attempts to control it. Good sleepers, asked how they get to sleep, generally can't tell you, because they don't do anything. Poor sleepers often have elaborate methods. On Espie's account the methods are part of the trouble. Once you start watching for sleep, wanting it badly and trying to bring it on, you've brought attention, intention and effort to bear on a process that works only when they're absent.
You've met this elsewhere in life. Falling asleep is like trying to remember a name that's on the tip of your tongue. The harder you strain, the further it goes, and it arrives by itself once you've stopped trying.
The NHS advice to the public is consistent with this. Its guidance on sleeping better says that if you're lying awake unable to sleep, you should try not to force it. When you're comfortable and resting, it says, you may find you fall asleep naturally.
So both of the obvious remedies make things worse. Ordering yourself to stop thinking keeps the thoughts active, and ordering yourself to sleep keeps you awake. The aim during a waking is something gentler. You give your mind something harmless to do and let your body rest. Whether sleep comes is out of your hands. It usually comes.