One of my favorite aspects of table top gaming is building and unfolding massive stories, but sometimes things go wrong. Plans fail, games dissolve, and sometimes your players just aren't interested. Whatever the cause the longer the the story the more likely you are to eventually have your plot either explode or dissolve. While there's no sure fire way to avoid this from happening, there are some tricks to help lessen the blow.
It's not all about you:
First thing any decent GM needs to understand is that the stories at the table are everyone's and not just theirs. Sure you might have a great idea for a story, but if it involves you controlling every aspect of every character and their actions then you're better off writing a book. Some GMs get confused with what a "rail-roaded" is and basically reading their fiction to their friends and telling them to roll dice.
Flex don't break:
Be flexible. This one might seem the same as the advice above, but it's more subtle. Sure you might understand that this is everyone's story, but until you realize that you can't actually predict everything from the beginning then you're just waiting for disaster. Again some GM's like to run more rail-road like adventures and this isn't me saying you can't. Instead loo at this as planning some alternative routes for when one of your players drops a boulder on your main set of tracks. If you're adventure is just plot A to plot B in a straight line with no where to turn or go around then one road bloc can bring the entire story to a dead end.
It's about the problem not the solution:
This is more of a tip for how I (any many others I've taken this tip from) run adventures. Do NOT write your entire adventure. Instead try and thin of the problem your players will have to face. IF it's a problem created by a Villain NPC then think about what that NPC wants, what their plan is, and what tools they have at their disposal. Let the players come up with the solution. The other advantage is understanding the NCP's motives and tools you can then think about how that character would deal with their plans being foiled one way or another by the heroes. This basically let's you plan as a character that has to shift and adjust just lie the heroes. The only thing I would say to be careful with there is that if you look at yourself as playing the Villain NPC do remember that the NPC doesn't have the magic power of DM to rewrite rules or give them-self things that they didn't have before just to "win".
Nothing will survive player interaction:
One last bit of advice is to remember that n matter how much you plan and what you write nothing you can do will survive your players. Be ready for plans to change and work to never be seen. If you go in thinking your story will run exactly as you predict you're just setting yourself up for disappointment.