Terrorism. They are afraid that Afghanistan would become a breeding ground for terrorists. May I dare say they fear the same for Pakistan, especially considering they have nukes.
Although, I'd have to say that Iraq was a disaster. But glad that the Iraqis are getting along somehow now. The sentence - War on Terror is a bit of an exaggerated statement.
Key for Muslims is to opt for a strong state as per Muslim-majority country. I think some Muslims folks just couldn't tolerate the fact the Israel defeated the Arabs so decisively four times in a row. That's partly how Muslim extremism came about.
So, if they are there to prevent that, why are they leaving: there has been very limited capacity building of Afghans, as yet, the Taliban, still, have a lot of clout. Occupation never solves problems, they should have let Taliban extradiate OBL, tried him in court & sent a message that see he did wrong, we got him. Mind ur own business, and we mind ours. Further, they could have spent the trillions of dollars on homeland security.
And Pakistan can do very well without America's concerns. TTP is a CIA offshoot, my father has served in ISI & I know this very well. Twice in 2007, we pinpointed the location of Mehsud to CIA & both the times they helped evacuate him, instead of sending in a drone. We also know what for Mr Davis was here. We also know why US does not let us fence the Pak-Afg border.
The last war was lost by Israelis, please. And the root cause of extremism has been oppression. The day Palestine, Kashmir & oppression elsewhere ceases, we will know peace, atleast brighter than today.
Conclusion:
Extremists always prey on insecurity among masses. The key to success is to beat the terrorists in their own game: Address their insecurities, sentiments and frustration! Rob extremists off the very ground, they stand on.
That's the long term & conclusive solution...