The villain should always have an escape clause. Always.
This is not to say that the PCs can't triumph. You can let them capture the villain and slap him into prison. But guess, what? You can escape from prison. Especially if you're a master villain.
The longer you keep them from truly defeating the villain once and for all, the more villainous and epic your creation becomes, until he ends up going down in the annals of roleplaying lore. This is the guy your players will remember for the rest of their lives. The massed orcs and giants, and even dragons don't matter if they just end up getting killed and donating their life savings to the PCs' gambling and wenching fund. The one they'll remember is the one they could never quite defeat.
Until the very end of the adventure, or even the end of the entire campaign. Then you have the Ultimate Showdown. Let the villain make an epic last stand. Here, you can let the PCs win. But do not let them simply kill him. Have the fight cause some sort of appropriately apocalyptic explosion, or landslide, or volcanic eruption, or something. The PCs can watch the villain suffer some sort of almost certainly fatal accident. Tha villain is defeated and killed! Allow the PCs their adventure-ending celebration.
Of course, the PCs should never get to see the body.
Then later, if they come back for more in the same campaign, the inevitable happens.
Transcript
Obi-Wan: General Grievous, you're under arrest.
[SFX]: Krzrk
General Grievous: Someone once asked me which I prefer:
General Grievous: The wafting aroma of freshly cut grass on a fine summer's day, or the exhilarating tang of ozone in a thunderstorm.
General Grievous: It was a difficult question to answer.
General Grievous: The heady scent of lazy days of mis-spent youth, or the opportunity-laden promise of excitement and danger.
General Grievous: And do you know what I finally said?
[SFX]: Krzrk
Obi-Wan: I can't even begin to imagine...
General Grievous: Air is for suckers.
[SFX]: Krack!! {Grievous smashes the bridge window}
[SFX]: Whoooosh!!