The thing I find most helpful is to make sure that there are always several parts of the system that I'm actually working on. This means I've got a choice of what to work on today (autonomy!) and can somewhat context-switch my way around the awkward bits (which sometimes get less awkward after a few days on the back burner). Don't get carried away with this (spending all your mental cycles deciding what to do next won't help, either), but it's worth a try. It's one of the things that makes me love largish solo projects.
I don't know how you work but usually the first couple months are a frenzy of work non stop but if I pace out the end a little better it becomes a lot more palatable. Also it's not the end of the world to take a couple days off if you come back with a clear mind ready to work, in fact it's usually more effective.
One more thing that really helps with overcoming the blues at the "almost finish line" is to get it in front of a few people and let them pick it apart. It gets me motivated before showing it to him/her/them to polish up any loose ends, and then after I have a new list of stuff that I feel motivated to resolve. Hope that helps! Goodluck w/ the project!
Like the old saying goes... "How do you eat a whale? One bite at a time."
Make sure you have sub goals nested at least three levels deep from your main end goal. Keep track of that stuff, gamify it for yourself. Keep a schedule, but keep it flexible and be understanding with yourself.
Discipline is a very difficult thing (the personality aspect of conscientiousness, look into it). The very definition of non-trivial and has plagued humans since time immemorial.
Knowing this gives me the motivation to push through.