As the Trump administration nears a peace deal with the Taliban, a key Republican senator said he will introduce legislation requiring that the secretaries of State and Defense certify that withdrawing troops from Afghanistan won’t put the U.S. homeland at risk of a terrorist attack.

Sen. Lindsey O. Graham (R-S.C.) said in an interview Wednesday that he will introduce this certification legislation as soon as next month. He said Senate Majority Leader Mitch McConnell (R-Ky.) had said he would support the proposal.

This requirement that administration officials sign off on troop withdrawals is the latest sign of Graham’s worry, quietly shared by many senior military and national security officials, that President Trump and potential Democratic challengers are racing for the exit in Afghanistan without paying enough attention to the potential dangers of a hasty withdrawal.

Trump’s special envoy Zalmay Khalilzad is nearing the final stages of a deal that reportedly would cut U.S. troops to about 8,600 immediately, from roughly 14,000 now. If conditions allow, according to one source, U.S. troops could be cut to near zero by October 2020, in time for Trump to say he delivered on an election promise. Khalilzad’s next meeting with the Taliban is set for Thursday, and it’s possible that he could wrap up remaining issues and announce a deal by next week.

Graham’s idea is to introduce a backstop to make sure that troop cuts promised as part of a peace deal don’t leave the United States vulnerable. He said the bill would require that the two Cabinet secretaries recertify every 180 days that ongoing troop withdrawals don’t endanger the United States. This would provide a mechanism for a regular intelligence assessment of the potential terrorist risk, as U.S. forces in Afghanistan decline.

As commander in chief, Trump could continue withdrawals even if the two key Cabinet officials refused certification, based on their reading of U.S. intelligence reports. But Graham says that defying advisers in this way could damage Trump politically in November 2020.

“It would be devastating for any president to withdraw forces from the country where the 9/11 attacks originated, after the secretaries of defense and state and the intelligence community said this would not be safe,” Graham said.

Pentagon officials declined requests for comment Wednesday. But Graham’s proposal would probably get support from senior military officials, who have worried about troop withdrawals at a time when the Islamic State’s Afghanistan affiliate is becoming stronger and more aggressive. National security adviser John Bolton is another likely supporter.

Khalilzad’s pact with the Taliban, if it can be finalized, would be a remarkable achievement. But its pillars remain somewhat wobbly, as he begins what could be a final round of talks in Doha, Qatar. The United States is promising to withdraw its troops in exchange for a Taliban pledge to halt external terrorist attacks — but the Taliban can’t offer any such guarantees about the Islamic State or al-Qaeda, which are still potent. The pact also envisions a cease-fire, but the Taliban hasn’t been ready to give up its leverage of violence, and the fallback may be a much weaker agreement not to target civilians. And finally, the future of the intra-Afghan dialogue that will follow Khalilzad’s pact is murky, at best.

Graham argued that his certification proposal would “focus attention on the homeland, not Afghanistan,” a faraway war that most Americans want to end after 18 frustrating years. Another benefit, it seems to me, is that it would also make intelligence assessments of terrorist threats the driver of this crucial decision, rather than politics.

Read more:

Liz Cheney: How to lose a war, but not end it

Morwari Zafar: The road to peace in Afghanistan must begin with national reconciliation

Ryan Crocker: I was ambassador to Afghanistan. This deal is a surrender.

Nadia Murad: I am a survivor of Islamic State violence. Don’t forget us.

Zalmay Khalilzad: To fight the Islamic State, Kurdish and Iraqi forces need expedited aid