I assume that you are talking about ending this particular war -- not ending the possibility of all wars in Afghanistan ever.
One possible way to end the war would simply be for the United States and NATO to pull out of the country and leave it to the Afghans to decide what sort of a country they want. This would end the current war, but it would surely cause a war between the current government and the Taliban (and possibly other groups). This would be the simplest way of ending the current war.
A second possibility would be to make a deal with the Taliban. This might include coming to some sort of agreement in which the current government would give the Taliban some amount of power. A deal would presumably have to include a promise to abstain from allowing Al Qaeda or other terrorist groups to operate in Afghanistan.
This, too, is rather improbable since the Taliban might well refuse to make such a deal.