I talk about this a few time here, and I try to enforce myself too to get enough rest. Maybe it works when you are young or without much need to care about what happens in life. Those days spending lots of sleepless nights to grind the solution should be gone, it does not work that way anymore, you should grind smart, not grind hard.
This tweet nailed it - Great Pro tip for programmers. Sleep and try again tomorrow.
You can see the followup reply by others, almost everyone has the same experience, take a break, have a shower, take a walk, and you might suddenly have the solution for what you are doing.
I saw it somewhere that talk about working 8 hours or more is something inherit since the industrial age, it doesn't suitable for the modern day work, you can't focus coding for more than few hours, it going to drain you.
It always happens to me when the first few hour coding, everything goes smoothly, then suddenly stuck in some bug or implementation, then I keep grind on it for a long time, until I give up and call it a day. The next day when I start fresh again, and it gets solved, this happens almost every time, the critical part is myself need to realise I stuck at the wall and it's time to rest.
Same things for my product development every night, after working hard on the day time, I don't feel like doing much more in the night time, so when I m exhausted, I do some simple enhancement for my product. When I in good condition, I work on it more. Not forcing myself to spend tons of time on it when I can't get in the zone, it just going to waste time. But I do force myself every day must spend some time doing something on the products, it only not necessary something that is going to continue to drain me.