You should never just let the BBEG escape: it cheapens the story. There are, however, ways to accomplish this. First and foremost, I think you need to give something of a reward to the PC's for winning the encounter. Maybe a potent magical item of the BBEG, or a limb, as mentioned. Depending on the adventure you're running, perhaps killing (or capturing, as you mentioned) his Captain is enough, provided the PC's know of his importance in the scheme of things.
Another possibility mentioned was letting them kill the BBEG, and have it not be him. Now, if it's a large battle, the BBEG might have summoned someone to command his forces. Maybe he isn't that much of a battle strategist, and has a demon summoned to deploy his minions more effectily than he would be able to. In this case, it is entirely possible for this double to be polymorphed into the leader, but as soon as he is dead, he returns to his normal form.
Yet another approach would be to create a situation wherein the PC's have to make a choice: either they get the BBEG now, or they rescue someone. Without more details from the adventure I can't give you a realistic scenario, but if the PC's have allies there could be another fight going on nearby (even one that had allowed them access to the BBEG in the first place), and a simple Whispering Wing or Message could convey the need for help. At the same time, the BBEG should probably receive reinforcements of some kind, so as to make it a choice between staying there or going to save others. If the PC's choose to slay the BBEG, I'd say let them have it. They will lose one or more allies, and the adventure can probably still be finished if someone else steps into his shoes (a good opportunity to twist the adventure around, and bring an auxiliary character into the limelight: maybe he/she even planned the event to reach power, and it's even better if the PC's met him/her before and it hid its true identity, skill and power). If your PC's are heroic, however, they will probably rescue their allies, and win a bittersweet victory over the BBEG.