Another thing I do that works well for me is just counting breaths. On the breath in I think "in-n-n-n-n" and on the breath out I count. When I lose count, and I am still awake, I start again from 0, as any sane programmer would ;-).
ETA: For a couple of months I have been doing a short gratitude routine as I am getting into bed. I acknowledge the good and positive things that happened during the day, and I tell myself that I did a good job (if I did) or that I did as well as I could today and that's good enough for today. Then I think, "And now it's time for rest. I've been looking forward to this." If any part of me starts thinking about the day again or thinks about tomorrow, I gently reassure it that I will attend to all of this tomorrow morning and that now it's quiet time and time to rest.
All of this plus 250 mg of magnesium an hour before bed has made falling asleep super consistent and easy.
Here's his technique: pick a letter of the alphabet, and find as much words that start with this letter as you can. Once you can't find words anymore, pick the next letter. Doesn't work for me, my brain won't ever stop.
I noticed I have to visualize stuff in my head to fall asleep so my adaptation is to pick a single letter and a single word, and visualize it in my head, using it, manipulating it, experiencing it, whatever. For example: letter P, word Pineapple, imagine you're holding a pineapple, you feel the roughness of it's skin in your hands, you throw it in the air and catch it again, you take a knife and slice it on a wooden table on the beach, etc.. The dream kicks in seconds. Without external interruptions, after a few minutes I'm asleep (instead of rummaging for hours).
If you notice you're stuck in a loop/pattern (for me anything about text, like reading or writing, and voice, like listening and speaking, or stressful scenarios), just pick a new letter, pick a new word, visualize it.