One important way to calm the racing thoughts in your brain is to focus on the body—specifically by slowing and lengthening your breath. You thereby temper the release of those stress-inducing hormones, so that the parasympathetic part of the nervous system can take hold. Your heart rate slows. Your blood pressure drops. As your body relaxes, your mind calms down, too, all of which help to ease your transition into sleep.
What works is something that engages your brain enough to distract you from your racing thoughts, but not enough to keep you from sleeping.