Just like with George H W Bush and George W Bush in Iraq:
Mr. President, either get the job done in Afghanistan or get out.
Don't just play around with it. Let the men and women who are trained to take down an enemy do what they are trained to do. Or bring them home.
Either way, finish there. Don't drag it out for the next eight years and wait for somebody else pull them out for you.
My personal preference: Take out Al Qaeda and the Taliban. Completely. (I am considering that "if you cut off the head, the snake will die;" ex-members of a dead group don't need to be individually taken out unless they are themselves a continuing threat.)
Don't play around with threats to our national security. Like poisonous snakes, either kill them or leave them alone. We don't want to get bitten again, because that would probably mean thousands (or more) of more people would die.
Of course, if they nuke DC, we'll get a new Congress and Senate out of it... But that's no excuse for the collateral damage of possibly millions of people to die because you just wouldn't let our military and intelligence services do their jobs.
It should be quite simple, really. We know our services have the ability to infiltrate them, a few people in varied positions. They can take out the leadership. In a manner that allows deniability, obviously. (Yea, the Taliban leadership must have gotten some dirty water or something. Always drink UPstream from the horses. We had nothing to do with it...)