A friend taught me a very useful trick to use when you really want to get to sleep but your brain can’t stop bouncing around randomly. Start counting and visualise each number, tracing it out in your visual space. Replace each number with the word ‘sleep’ before going on to the next. Or imagine it like a count-down strip in an old film reel, with the number 1 being surrounded by a clock face sweeping out the time to the next number. Slow that time down between numbers. Or write the words out in your head. Or count in a foreign language, again tracing the words out in your head. Try binary or trinary.
The key detail here is to not just think of the number but to visually map it out in your visual space, so it involves more of your brain to trace each number. If you also involve a picture or a word that you have to put between each iteration, it forces your brain to concentrate on one thing. And that’s really the key to that ‘brain pinball’ feeling – stopping every bit of your brain firing randomly.
The other technique I’ve used is to count up in series. Powers of two or three, the Fibonacci series – there are plenty of other arithmetic (and a few simple geometric) progressions that you can use to focus your mind. Now that I can count up to 2^24 from memory it becomes more of a challenge, but it’s a good way of concentrating to stop your thoughts randomly running all over the place.