I suffer from Insomnia, I have for many years, I'm up at 1am after a day which I let me discipline slide. I didn't feel as productive as I should've been today, So you know what I did? I worked till 8:30pm. I punished myself. I broke my new golden rule of getting off the computer by 6pm, which was working so well for me.
Then what happened? I didn't have any wind down time, then I couldn't sleep and now I'm up stressed about everything I probably won't get done tomorrow because I'll be too tired to focus on complex tasks, it's now a compound fracture, a cluster bomb of issues.
I think you're 100% right. Just walk away while you still can, retreat, then come out on the attack the next day feeling better.
I wish I'd taken my own advice.