Really, the book "Nixon and Kissinger" should be required reading as the discussion about ending the war in Afghanistan starts to pick up. We should stay and fight in Afghanistan if we think our interests are at stake and we think we can win the war (however defined). By contrast, we should leave Afghanistan if our interests are no longer at stake, or if we don't believe there is a reasonable strategy through which a victory could be accomplished, given human and financial considerations. In other words, if we "win" by sacrificing thousands of soldiers' lives and trillions of dollars for meager gains, we didn't really win. We just lost in a different way.
What we should not do is stay and fight in Afghanistan so that we can "exit with dignity". That is exactly what Richard Nixon did in Vietnam. Nixon sacrificed the lives of thousands of US troops in a war that he knew we weren't going to win, and a war that he was actively terminating, because he did not want a stain on his honor (and we all know how important Nixonian honor turned out to be). We ended up losing Vietnam without dignity anyway, as the world quickly saw what a farce the face-saving agreement with the communists was. Remember helicopters evacuating the US embassy in Saigon?
The long term consequences of the US withdrawing from Vietnam without dignity were precisely nil. Nobody doubted our strength in the long-term, even if morale was sapped a bit in the short term. I would argue that morale would have been less damaged in Vietnam had we ended the war sooner and saved thousands of lives, though. Furthermore, from the perspective of credible military deterrence, America would be more feared by non-state Al Qaeda types if they believed we could get involved in effective short-term military operations without always settling down for a decade-long war.
The reason I brought this up was because I saw some candidates at the Fox News GOP Presidential Debate say that we should make sure we exit Afghanistan with dignity. The suggestion that the lives of US soldiers are worth less than such petty superficiality is nothing less than reprehensible. Any politician who places priority on such nonsense should send their sons to execute the last face-saving operations of the failing war. The politician who puffs their chest out and talks a tough game about "honor" and "dignity" when sending other peoples' children to fight and die is the worst sort of politician there is. I wish Americans could see through that garbage.