You're in the middle of writing chapter whatever and suddenly you realize that while you've been working out this or that you have also dumbed down your character to the point that a screenwriter could easily retitle your novel Honey I Shrunk The Protagonist's Brain.
Outlining, as Zornhau mentioned yesterday, is an excellent early diagnostic, and can keep you from having to perform an imbecilectomy. But not all writers are comfortable with outlining or planning out a novel, so this won't work for everyone.
By-the-seat-of-the-pants writers have to make it up as they go along, and while I understand the appeal of spontaneous creative freedom, it can contribute heavily to this kind of problem. Not knowing where you're going makes it hard to figure out what the novel road is going to be like. You're more prone to take speedy detours that seem perfectly logical while you're right there, trying to move the story along. Only when you look back do you realize that there might have been a better way to handle that -- and then you rewrite.
Rewriting is going to depend on how extensively you've used the deliberate idiot detour. Sometimes you can go back, edit like a fiend and salvage the novel. Sometimes you have to scrap whole plot threads and/or characters, and weave in replacements. If it's totaled the book, though, all you can really do is scrap it or start over from scratch.
One way I think the spontaneous writers out there might swing imbecilectomies is to avoid quick solutions to a character reacting to a plot point. When you hit that spot, don't make the character do something for the story's convenience. Example:
The power goes out suddenly. Jane, who is alone in the house and has been receiving threatening phone calls for weeks, hears the sound of breaking glass coming from the basement. She grabs a flashlight and heads for the basement stairs. Killer grabs her off the stairs.
Right. Did Jane stop and think here? Did she check the phone? Did she grab her car keys and run to the garage where her car is? Did she arm herself with one of the knives from the kitchen? Nope. Because the author wants to confront the killer in the basement, Jane has gone totally brain-dead.
Now, try this:
The power goes out suddenly. Jane picks up the phone and discovers the line is dead. She hears the sound of breaking glass coming from the basement. She slams the door to the basement stairs shut, locks it, grabs her car keys and runs to the garage. Her car tires have been slashed and her engine sabotaged. The garage door is wedged shut. She hears the locked basement door in the house being kicked open. She arms herself with a pair of hedgetrimmers and screams for help as she tries to break out a window. Killer hauls her back away from the window.
How else can Jane confront the killer without acting like a moron?