Sometimes the reason I can't fall asleep is that my mental engines are just too active. I'm not worried per se, there are just too many interesting things to think about. Sometimes in response I'll do prime factorization of numbers in my head. It requires focused attention, and is interesting enough that I can actually focus on it, excluding all the other things I was thinking about, but not so interesting that I'll fight sleep to do it. Sometimes listening to Chinese does the same thing: it's interesting enough to focus on (and exclude whatever else was keeping the "engine" going), but not so interesting that I'll fight sleep to pay attention.
If I were to pull an explanation out of my behind:
Iād say this is a complicated enough exercise to keep you focused on it and not drift to other topics, yet so utterly boring as to not keep you awake in anticipation of what happens next.
Then perhaps after using this technique for a few days your brain might start to recognize these neuron patterns as the shutdown sequence.