Burnout happens when stress isn't followed by rest. When stress feels endless. And when stress feels like it's pointless.
The solution therefore is to make sure you always know why you're working so hard, build in reward for your hard work, and take a break after a specific period of stress.
Always have the end in sight. Always know your goal. Always make sure you feel progress toward the goal.
Crucially, when the specified period of stress comes, take a fucking break. Whether you're done or not. Very important.
I myself often fail to follow these lessons. So I write them here to help me remember :)
PS: for a more in-depth exploration of these 3 rules, read Peak Performance. It helped me a lot.