I've noticed this about most of the books I write, except for my short stories/novellas. When I get close to writing the end, my thoughts become a chaotic mess, and I don't know how to properly formulate my last few chapters, so I give up. It's odd, though, because when I write shorter stories, I don't have this problem; it's only when I write more than twenty chapters.
Endings are actually the biggest problem that discovery writers face. Plotters usually have the most trouble in the middle; discovery writers tend to progress fluidly through the middle (because characters are just being who they are), but that creates many complications and they have trouble in bringing all the arcs to a close simultaneously.
I am a discovery writer; I discover my characters and my plot as I write.
However, there are still rules to follow. For one, my stories always have a "big problem" that the hero has to solve. I don't start writing until I know what her big problem is going to be; that is basically my story idea.
I also don't start writing until I have thought of a plausible way to solve the big problem. This doesn't have to be complicated, it can be quite simplistic -- In Taken, bad guys kidnap Liam Neeson's daughter, Liam kills the bad guys and saves his daughter. That's the story, everything else is authorial decisions that can be made on the fly. Including making the bad guys sex slavers, making his daughter a pretty young teen, making Liam an expert commando, including the settings, nationalities, even the time setting.
I could change all of those things and have a different movie on the same premise: bad guys kidnap Danny DeVito's daughter, Danny kills the bad guys and saves his daughter.
As I write and discover my characters and the plot around this central premise, I keep notes (not 'finished' prose, just notes) on what I need to wrap up in the ending. I basically do this scene-by-scene, when I think I have a first draft of a scene, before starting the next scene, I look for anything I have done that makes my ending implausible, or impossible. I read my ending notes.
If I write something inconsistent with my ending, I have to come up with a better ending that is still consistent, or I have to undo this scene, or revise it, so my ending still works. I don't write further without a way to end the story; those notes are my "compass direction" while inventing the plot and complications.
I often change my ending 3 or 4 times in the course of writing a novel; always to a better ending than my first conception. I have scrapped more openings than I can count because I thought of better motivations and goals for characters. I have scrapped whole scenes, whole conversations that, even though they sounded natural at the time, revealed critical information too early and would ruin some surprise I had for my ending.
As for bringing all the arcs to a close simultaneously: As I write, once I have passed about the 2/3 mark in the story, I stop complicating the arcs, no more invention of complications. I start looking for ways to resolve them, and wrap things up for each character. Things start getting solved. The BIG problem won't be solved until about the finale, in the last 10% or so of the story, but everything else starts getting tied down; I am looking to invent simplifying developments to answer outstanding questions, complications, etc.
You have to shift your attention to "ending mode" so subplots, relationships, mysteries, etc get their answer. You want that stuff out of the way when you get to the finale. Think of it as four parts of the story:
- Things are simple, we have a big problem.
- Things get complicated, we have a lot of problems.
- Things get uncomplicated, problems start getting resolved.
- Things get simple again, then we solve the big problem.
You can be a discovery writer and follow a writing plan, it isn't a plot you have outlined with twists and turns, it is just the type of writing you need to do at each stage of the creation process.