I've talked before about the different kinds of campaigns that people run for their table top groups. The 'exploration' type game, where the purpose of the game is essentially to just explore the world that the GM has created and not focused on any particular story above and beyond what the players may make for themselves. That is not the kind of game I'm going to be talking about today, because honestly I'm not very good at running those.
The other two kinds of game though are centered around a story. There is a plot, a cast, events that happen, and something that often gets forgotten about at times. An ending. Now, endings are funny things when they come to games. After all, they can rear their ugly head at almost any moment with the dreaded TPK, but other times they can seem so far off that you can't even see them anymore. When that happens, games have a tendency of falling off track and becoming more rambling affairs, something that can lead further to the PCs scattering to the four winds and an in general lowering of fun around the table.
This isn't always the case mind you, but it is something to be aware of. The solution to it? Keep the ending in sight. Just because the Villains/Antagonists aren't on screen doesn't mean they are not doing anything. Have them furthering their goals even when off screen, not just waiting around for the PCs to show up to get them. You have to pace it of course, give the PCs some time, but if they start to loligag nothing says the villains can't take a step forward with their plans. Even better though is that by doing this, your world seems more a live. Things progress even when the players aren't there and it brings the world to life. It shows that while the story may revolve around the players, the world doesn't and not paying attention to things can mean missing it completely.
The hardest part about keeping an ending in mind though is that in truth you actually need to keep multiple endings in mind. If there is only one possible ending for your game, write a book. Everything converges on one point, and if that point can't change to fit the game you shouldn't run one because by the end you will be railroading, fiating, and retconning to make everything fit into your ending. So try to keep multiple endings in mind, multiple possibilities that can happen either in lumps or simply as pieces that can go together in different ways.
The details of how specifically you do it though aren't important. What is, is that the game is working towards some sort of end point. That while the game goes through it's various rises, climaxes, and relaxes it is also building up to The climax for the game, the Grand Finale where the loose ends get tied up (or not ;) ) and the story comes to a close.
Keeping an ending in mind helps give the game structure, it helps keep the players in line and stopping from going off on dozens of little small things that can bog down the game and remove the fun. It essentially lets you keep guide reigns on the flow of the game. Once you have those reigns in hand, you can steer the game towards what will bring the most fun to the group as a whole.
So, next time you are GMing and things seem to be getting bogged down and scattered, especially when you can't even see the main plot line from where the PCs are standing, remember the endings you had in mind when the game started, and what could be going on to bring about those various endings just needing the PCs to nudge it in the right direction. It should help you get things back on track, unless of course everyone is having more fun off the track.