If you have thoughts in your head instead of collected somewhere you trust yourself to check then they will bother you while trying to get work done.
You'll want to use the first step of the getting things done (GTD) framework. It's worth learning the whole system eventually but I recommend people just start with the first step. It has a huge immediate payoff in terms of stress and productivity. It's also a lot easier to implement one step than five at a time.
Capture is that first step.
Take a piece of paper and just list out every single thing you can think of in a bullet list. Don't worry about clarifying anything or being too specific.
Your mind will now have some breathing room. Pick an important item and start going at it.
While not a long-term solution, this is much better than not having any system. If for some reason or another I get behind on my productivity system, be it stress, vacation or whatever, I will always use this as soon as I recognize the problem. The capture step is my support structure.
Here's a "trigger list" that will help you fully empty your head: https://gettingthingsdone.com/wp-content/uploads/2014/10/Mind_Sweep_Trigger_List.pdf