You've discovered the secret. When things start going badly, it's time to walk away. Your brain will reset and you'll be off and getting everything correct once again when you go back to it. Aren't our brains a fantastic thing? If I go to bed with a difficult puzzle that I couldn't finish, I'll get up in the morning and my brain will have figured it all out. I'll be able to finish it a short order.