If I'm building something and the code gets messy I increasingly feel frustrated while working with it which turns me off from working on it - somewhat of a negative feedback loop, so when I start to feel like the code is a hassle to work with, I switch gears from writing features to refactoring the existing code-base.
This gives me a nice change of pace, lets me think a little bit differently than simply "add features", and when the refactoring is done I have a much more thorough understanding of the code I've already written and what needs still needs to be done.
It seems like a pretty simple and obvious suggestion but I can't tell you the number of times I've let a personal project become unmanageable just because I've wanted to keep adding features which at least for me leads to burnout.