I don't think its an issue of winning or losing. The goal of going into Afghanistan (expelling AQ and getting Bin Ladin) was accomplished 19 and 10 years ago respectively, so there was nothing else to accomplish other than transitioning into an advise and assist NATO mission, which is what its been for the past decade. If after 20 years, the Afghan government isn't able to deal with corruption, pay its troops a livable wage so that they fight for the nation when needed, create national unity to get all Afghans around a political process, then that is not a loss of foreign forces supporting them. The US could've easily stayed in Afghanistan for another 20 years with a few thousand troops on the ground, but ultimately if the will to fight among Afghans isn't there, then it was time to leave.