Ever since the Obama administration announced that all US ground troops would be withdrawn from Afghanistan by the end of 2014, I have argued against calling this an “endgame”. After all, according to the plan, America would in fact retain huge air bases and many thousands of Special Forces and military advisors in Afghanistan until at least 2024, when the present military co-operation agreement with the Karzai government expires.

July, however, saw the emergence of the possibility of a real US endgame in Afghanistan next year. White House officials issued semi-official statements that the US may imitate the USSR in 1989 and supported all these years. Moreover, they reflect deep concerns about whether the entire rickety edifice of the existing Afghan state and army can survive next year’s combination of the withdrawal of US ground troops and the Afghan presidential elections, which are certain to be both deeply corrupt and bitterly contested and risk producing a president who lacks all legitimacy, even among most people on the anti-Taliban side.

The Obama administration is now engaged in a rather desperate effort to save whatever can still be saved from the wreckage of Western hopes and plans in Afghanistan. Whatever one’s criticisms of past US policies, they deserve the support of the US political elites and allies. The two key goals are to preserve as much US military prestige as possible and to leave behind a situation in Afghanistan which will allow US troops to leave with reasonable order and dignity. The ultimate nightmare is of pictures like those from Saigon in 1975.

Until recently, US fears were focused on a Taliban victory, but, in fact, the notion of the Taliban sweeping to power in Kabul, while not impossible, is relatively unlikely given the forces opposed to them both within Afghanistan and in Afghanistan’s region. My own judgement would be that if the war continues, the Taliban will sweep the great majority of the Pashtun areas of Afghanistan, but that they will face great resistance — backed by Russia, India and Iran, if not the US — if they try to conquer Kabul and the non-Pashtun nationalities.

What has gradually dawned on Washington, however, is that the Taliban are not the only threat to any US soldiers and officials who remain in Afghanistan after the withdrawal of US ground forces. These will be in danger not only from Taliban attack, but also from an implosion of the Western-backed side if next year’s elections fail to produce a legitimate result, or if Hamid Karzai decides to violate the constitution and stay on as president. The consequence might well be violent divisions within the Kabul political elite and the Afghan National Army.

In Kandahar and Helmand, the result might be a withdrawal of US advisors and Special Forces in the face of a victorious Taliban offensive. In Kabul, residual US and Western forces might find themselves in a scrambling evacuation from the midst of a civil war between different forces on “our” side. From the point of view of US military prestige, it is hard to say which would be worse.

Hence the new US push for peace talks with the Taliban, but also the suggestion of complete US withdrawal next year. In the first instance, this suggestion is intended as a means of pressure on the Karzai administration to accept a peace process with the Taliban — even though, to judge by the remarks of every single figure close to the Taliban with whom I have spoken, any successful process would inevitably lead to the complete removal of President Karzai and his clan from power in Afghanistan.

But if Karzai and his followers continue to resist, or if no peace settlement with the Taliban proves possible, then a withdrawal of every single Western soldier next year may also be the only way to leave with dignity and avoid a complete, bloody, and humiliating scuttle further down the line.

In the 19th century, the British lost a whole army in Afghanistan in 1842, and the best part of another one at Maiwand in 1880, yet went on to win both those wars. They also lost two diplomatic missions to Afghanistan and their military escorts, slaughtered in Kabul in 1841 and 1879. For that matter, the US lost 58,000 men in Vietnam before withdrawing — and they were conscripts, not the volunteer professionals of today’s US military.

But things have changed: today, the death or capture of one US advisor team would be seen as a bad defeat; the simultaneous loss of two or three would be a catastrophe. If US allies sustained such losses it would severely undermine support for NATO in the countries concerned. Faced with this danger, complete withdrawal in good order and in good time may well be the best option available — though one must also have the most profound sympathy for the US president who has to make this agonising decision.