President Trump tweeted Saturday that he’d called off U.S. peace talks with the Taliban. He canceled separate Camp David meetings with Taliban leaders and Afghan President Ashraf Ghani, set for Sunday.

Good.

Presumably, those meetings were the prelude to announcing a U.S. deal with the Taliban. Special U.S. envoy Zalmay Khalilzad said Monday that he had already concluded an agreement ‘in principle.”

But this accord – negotiated in direct U.S.-Taliban talks that excluded the Afghan government -- looked like a giveaway to the Islamists, with the United States getting little in exchange for withdrawing all remaining 14,000 troops by 2020 -- just in time for U.S. elections.

A breather is in order, to alert Congress and the U.S. public to the dangers of setting politicized deadlines for a deal.

Trump’s given reason for the break was a Taliban attack on Thursday that killed one U.S. serviceman and 11 other people. But there have been many such bombings.

More likely he paused the talks because he was feeling the heat from some conservatives since he looked as if he was about to mimic a crucial mistake made by President Obama – when he pulled all U.S. troops out of Iraq in 2011. That set the preconditions for the Islamic State’s invasion of northern Iraq in 2014.

“We cannot repeat in Afghanistan the mistake our leaders made in Iraq,” Trump insisted in a speech laying out his Afghanistan strategy in August 2017.

So why would he imitate Obama now?

The superficial answer is obvious. The president is frustrated that we aren’t “winning” in Afghanistan.

To be fair, most Americans are also frustrated at “forever wars” with no victory or obvious conclusion. Yet the time has come for Americans to reconsider whether it is smarter and cheaper to keep a small residual force in Afghanistan to prevent losing, and having to go back in.

“If the Taliban know there’s a timeline by the end of 2020, which isn’t conditional on an agreement first being reached and implemented, it will never take place,” says James Dobbins, U.S. special representative to Afghanistan in 2013-14. He and several former U.S. ambassadors to Afghanistan just co-authored a trenchant report for the Atlantic Council titled, “US-Taliban negotiations: How to Avoid Rushing to Failure.”

If Trump had his way, U.S. forces would be gone before it was clear whether the Taliban will keep its pledge to negotiate an intra-Afghan peace with elected Afghan officials. Or whether the group’s true intent was to reestablish an Islamic emirate (and end rights for women) by force. The latter course will produce a renewed civil war and an opening for ISIS 2.0 amidst the chaos.

In other words, it is worth maintaining a longer presence as leverage to test whether the Taliban is serious. Or to prevent a Taliban takeover of Kabul in case talks fail.

It would be far more costly to return to Afghanistan after an ISIS rebirth.

To understand how costly, consider what happened in Iraq in 2011, the example Trump cited in his 2017 speech.

In 2011, the Obama administration initially sought to retain 3,500-10,000 troops in Iraq, after drawing down most U.S. forces. However, the administration was deeply divided about keeping troops there; the White House ultimately claimed the Iraqis wouldn’t permit the troops to remain and brought the troops home.

After the last U.S. troops left, U.S. attention and intelligence waned when it came to Iraq. The Baghdad government politicized the Iraqi army command; Iraqi forces in Mosul collapsed when ISIS invaded in 2014

Eventually, Washington had to send 6,000 U.S. troops back to Iraq to spearhead the brutal campaign to wipe out the Islamic State.

Yet, I was told by senior Iraqi officials that there was another legal route by which the Obama team could have secured Iraqi approval, and probably have prevented the ISIS resurgence. That approval could have been obtained under terms of a strategic framework accord negotiated by the George W. Bush administration.

That is the basis under which around 5,000 U.S. troops remain in Iraq now, advising and training Iraqi forces.

The lesson of this sad Iraq misadventure is that it’s better to invest long term in not losing than to leave too soon.

A bit of Afghan history is also useful to understand the risks of a heedless pullout. When the Soviets withdrew from Afghanistan in 1989, the country collapsed into civil war by the early 1990s, especially when Moscow stopped providing military and economic aid to the government.

Out of that chaos emerged a Taliban emirate that permitted al-Qaeda to base and train on its soil.

The current Taliban leadership pledges not to permit any future al-Qaeda presence.

But once U.S. troops leave, how can the Taliban be trusted? Hard-line Taliban who prefer to keep on fighting are likely to join the local branch of ISIS or new jihadi groups.

Any intra-Afghan accord is unlikely to be negotiated by the end of 2020. So Trump has a choice. He can rush to failure, or he can focus on long-term strategy.

Unfortunately, his 2017 speech on Afghan strategy was written when James Mattis was defense secretary and H.R. McMaster his national security adviser. The Afghan talks may be on pause, but that kind of long-range thinking no longer exists in the White House.

These days Trump appears to make such crucial decisions all alone – and by tweet.

.