A friend who just finished writing a(n excellent) book in a short period of time says you have to ignore your brain when it tells you it’s done for the day. You may think you can’t keep going, but if you push on, what comes out will be even better. The next day, do the same. Repeat, repeat, repeat. Also, no socializing. Apart from whatever job pays the bills, do nothing but sleep, eat, procrastinate, and write.
See also Peter Straub’s Twitter bio: “my profession obliges me to enjoy solitary confinement.”