First off, let's call the beast by its name: burnout. When I'm working on things, my natural state is to use an unsustainable amount of brainpower. Sometimes I get recharge moments and everything works out ok, but at other times I reach the bottom and cease to be effective. Once I reach that point it's damn hard to get out of it. It takes weeks or even months to return back to the mindset of peak performance after burnout. I've experienced burnout quite a few times in the past, and I know exactly what to do to get myself back from it. But preventing it from happening in the first place, that appears to be a lot trickier. You need willpower to tell yourself to stop working on something interesting, and if you continue working at that point your willpower slowly slips away. It's easy to get lost. Especially if you're faced with the exact thing that would keep your brain busy.
An interesting problem is like a burnout virus for the mind. All you need is a problem that is challenging, exciting and complex, but also not complex enough to seem too daunting. Maybe you'll know how to solve 90% of it and the challenge of solving the remaining 10% is what motivates you to keep working on it. Then after you've worked it on for a while you start to realize that the remaining 10% of the problem is actually another problem that is as difficult as the original one. Once again, you know how to solve 90% of that problem and the remaining 10% is a challenge. Repeat ad infinitum. Or until your willpower is gone and you've achieved peak burnout. Congratulations.
Recognizing that you're about to get stuck in this loop is important. It's the mindset of believing that you'll solve these kinds of problems immediately, or by just devoting more brain-time to them, because then you'll get into the willpower-draining self-loop that eventually leads to burnout. There's always one more thing to solve; one more thing that needs fixing or thinking about. What matters more than solving the problem is keeping yourself in a state where you're able to solve problems. And draining yourself towards burnout is the exact opposite of what you should be doing. Take time off. Think about other things. Don't worry if you still think about the problem in the shower or before going to sleep, it'll drain itself from your brain eventually. No problem is as important as keeping your mental self in its best possible state.
(Yes, this post was totally advice to myself. Felt good to write about it though.)