The goal of invading Afghanistan was to prevent Al Qaeda from using it as a base, then the goal has been accomplished. Bin Laden is gone, Al Qaeda has been greatly reduced as a threat.
It is pretty obvious that the US cannot afford to spend the next 30 years or so trying to turn Afghanistan into some sort of Muslim South Korea. Karzai is basically scum, and we can hardly dispose of him. Pakistan is where any real problem lies, and the US cannot invade Pakistan, which had nearly 80 million people.
As a military campaign, Afghanistan is unwinnable. We must leave. If McCain were president, that would still be the only sane course.