One way to stop your thoughts from invading your mind would be meditation. Not all can master meditation from the first time they try, but it is definitely worth a try. You can start with something very small, like scanning your body and noticing how you feel instead of focusing on your thoughts. This should keep your mind occupied with something positive and sleep-inducing, at least for a while. Don’t expect it to function like a charm from the very first time, but the more you try, the better it will be. If you don’t fancy meditation, try reading before sleep. Boring books work the best. Choose easy reads in random topics. While reading, play white noise. One option that worked for me is Sleep Automatic, but you can choose other apps too, or play something on YouTube. The app is a more convenient option though, and it can become a habit quicker. Hope it helps!