If you want your writing to have decent grammar, it’s better to do it when you’re conscious (the brain, at least, should be awake). As obvious as that seems, when you’re trying to cram in writing with a full time job, family, friends, car repairs, etc., it’s not the easiest rule to stick to. There are plenty of writers who get their writing in after everyone else is in bed or before they themselves collapse for the night.
Like right now. When I’m writing this.
The only problem with that is that tired brains make more mistakes. Honestly, I make more than twice as many grammar errors when I’m tired or in a hurry (or, heaven forbid, both). And they’re the embarrassing types of mistakes – like typing the wrong “there” or using a possessive for a plural noun. I’m ok with some errors (I’m not the worst grammar Nazi out there). Too many, and I want to hide and apologize to the world for whatever I posted (like if I break the “Top 5 Grammar Rules Not to Break“).
It makes writing grammar articles moderately terrifying (Srsly, what’s more embarrassing than making the mistake you’re telling people not to make in the same article?). At the same time, it makes writing articles take twice as long. That’s because I can’t stand to publish them until I’ve read them a dozen or more times checking for errors (unfortunately, that’s not always an exaggeration).
A little ocd? Maybe. But it keeps the writing closer to the quality I want it to be.
Actually, that’s the general lesson I’d take away from this. I won’t tell you to stop writing in your sleep. For all I know, that’s the only real chance you have to write at all. If you do, however, be aware of the grammar (and continuity) issues it can cause. Be ready to edit more (preferably, when you’re awake) or to have someone do it for you. Don’t assume your tired brain has the same grammar skills it normally does.