When James Mattis resigned as defense secretary Thursday, the "guardrails" in Trump's administration came off, as The Associated Press somewhat worryingly put it.

Mattis has gained a reputation for trying to prevent Trump from indulging in his worst foreign policy impulses. With Mattis on his way out (he'll officially step down in February), let's take a look back at some of the instances of Mattis successfully reining the president in. Brendan Morrow

1. Killing Assad. Last year, Trump reportedly called for the assassination of Syrian President Bashar al-Assad, saying, "Let's f---ing kill him! Let's go in. Let's kill the f---ing lot of them," according to Bob Woodward's book Fear, per The Washington Post. Mattis immediately told an aide, "We're not going to do any of that."

2. Pulling out of Afghanistan. Trump reportedly told his advisers in 2017 that he wanted to withdraw troops from Afghanistan, but he ended up deploying 3,000 more at Mattis' direction, per Politico. In a speech, Trump said that his "original instinct" was to pull out but that he changed his mind after "many meetings." The same day Mattis resigned, it was reported that Trump would be pulling troops out of Afghanistan.

3. Sending troops to the border. Politico also points out that Trump wanted to send active-duty troops to the southern border in April 2018, but Mattis pushed back, sending National Guardsmen instead. Trump eventually did deploy troops in the fall, but Mattis broke from the president by saying these troops would not use force.

4. Torturing people. On the campaign trail, Trump promised to reinstitute torture methods like waterboarding. He never did, and Mattis seems to be a key reason for that; Trump said he was "impressed" by a conversation he had in which Mattis told him these methods are not useful, per The New York Times.

5. Pulling out of Korea. Trump, according to Woodward's book, expressed frustration with the U.S.'s presence in the Korean Peninsula, The Washington Post reports. Mattis had to convince him why this is necessary, saying, "We're doing this in order to prevent World War III."