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.