Make sure you get good night sleeps, and not staying up at night because of the stress. Brain fog is just tiredness and bad sleep quality.
Some days during writing up, I was waking up feeling absolutely tired because I had restless nights with stress-induced dreams. I learned to cut my losses: if it was one of those days, just took the day off. Go to the park, read a book, watch a movie. First try to fix your sleep patterns. Going to bed at certain times and waking up with an alarm clock same time everyday helps, also meditation before going to bed was helpful for me. The best was just going to bed thinking how much I don't care about the PhD.
Controlling the stress levels was one of the biggest challenges for me, and my biggest enemy. Just try to write a section a day, don't be too hard on yourself, at the end it is all going to fall together. Just keep going,