In order to avoid this, start looking around for the line of riders who are next to take over at the front. At this point, it is crucial that you don't get boxed in. Though there are many ways to prevent this, the simplest solution is to just create a little space for yourself. You don't need to make contact or even ride especially aggressively. By sticking your elbows out and possibly moving off your line just a bit you should be able to claim a little space on either side.
As soon as you sense a rider moving up the side, get ready to move over into his slipstream. There will probably be a few riders already on his wheel but chances are, if you time it right, you will be able to find a gap just big enough to squeeze into. Suddenly, you're back in the sweet spot, five riders back, jetting to the finish, still without having wasted much energy.
Be prepared to do this several times over the last kilometer of the race, especially in races with long, straight stretches to the finish. Riders tend to get twitchy as soon as the finish line is in view, so don't jump on the wheel of the very first rider who sprints by and count on him to take you to 200 meters. Instead, look for a solid flow of riders to keep you near--but not at--the front.
Much of this comes from experience, so you might not get it right the first time. However, just like finding the sweet spot, when you suddenly discover the natural ebb and flow of the final sprint, the last kilometer (which used to feel like madness) will suddenly seem like a smooth wave gently pushing you towards the beach.
Turn Your Ideal Script Into RealityYou're down to the final 400 meters. You're in position and ready to make the kill. Having stayed near the front for the last few miles, you are better rested than anyone else and it's your race to lose. What's your move?
Hopefully, you've scouted out the finish ahead of time. You've looked at the road surface, the direction of the wind, the distance from certain landmarks to the finish and the best line through the final turn. You've digested all this information and in your head you've seen the finish over and over exactly the way you want it to happen. You take the perfect line through the turn in fourth or fifth position, depending on the distance to the finish.
At the 25 mph sign, you grin and shift into your 11. At the light post you jump, moving up the left side onto a patch of smooth pavement and protected from the crosswind coming in from the right. With exactly 200 meters to go, you've reached top speed and optimal rotations-per-minute. You cross the line and it's the easiest thing you've ever done. You only wish you had figured this all out sooner.
You've run this script through your head so many times that when you reach the final moments of the race, it's easy. All you have to do is go through the motions that you've rehearsed over and over. Although every race and every finish is different, once you get a handle on the basic flow of the sprint, you will likely be able to nail it every time. You'll know you've got it right when you cross the line feeling like you gave it your all. Nothing more, nothing less. It will just feel right.
My final piece of advice is that nothing I could write could even come close to the education of experience. Race a lot, but don't just race, throw your helmet down in disgust and go home. Analyze your race. Figure out what you did right and what you could have done better. Don't think in terms of mistakes. There really are no mistakes, just opportunities to learn. Practice with your teammates once a week. Get the timing down in practice and then try to carry it into an actual race. As long as you remain focused and aware, even when the going gets tough, you're sure to gather valuable information in every race you do.