I watched an episode of The Practice many years ago where a lawyer argued that the United States army was obliged to finish its mission in any particular country it decided to wage war in, for the same reason that a doctor faces tricky legal territory if he or she stops at the scene of an accident.
In both instances, the illusion of taking care of the problem implicitly indicates that no one else needs to come in and take charge. In other words, if you do decide to involve yourself in something, make sure you finish the job.
This philosophy is very apt for the debate raging across US media at the moment about pulling American troops out of Afghanistan. We can argue until we're blue in the face about whether the Yanks should or shouldn't have gone in (I personally believe this war was far more justifiable than war in Iraq, but both would have been best avoided), but the fact is that US troops are there. This mission is soon to enter its eleventh year. There isn't any going backwards. Currently Afghanistan is somewhat unstable, with a government that is still battling/negotiating with the Taliban with a leader who doesn't exert effective authority (for more reasons that just his own weaknesses).
Afghanistan President Hamid Karzai has many faults (his lackadaisical attitude towards corruption and absolute hatred of women's rights being examples) including a lack of control over what is going on in his own country. The presence of the American army is assisting him in keeping violence to the level at which it currently finds itself (which is lower that it could be, believe it or not).
Recent events, the Afghan public's violent reaction to US troops burning copies of the Quran, and an expected violent reaction to a rogue US soldier systematically putting bullets into 16 civilians, have seen calls increase for the US to get out of Afghanistan. But while this is tempting, the US is responsible for the mission it decided to undertake in Afghanistan, and cannot just pack up and go. While it is terrible that the military is in more danger should it remain in the country, Afghan civilians are even more at risk from militants within the country should the soldiers (who are not shooting the people they are supposed to be defending) depart.
The US is under obligation to remain in Afghanistan until the country has been stabilised. Interior movements and the (outside) possibility of help from other countries will have been dampened by the entry of the USA and allies.
While hauling the troops home would suit the foreign military, it would not suit Afghans.
The US began this war and is obliged to leave a peaceful country when it departs. Packing up and leaving now would plunge Afghanistan into something worse than anarchy.