President Donald Trump on Friday removed his chief of staff, Reince Priebus, and tapped Homeland Security Secretary John Kelly for the job.

The stunning shakeup is the latest chapter in the West Wing drama that has unfolded publicly in recent days.White House Communications Director Anthony Scaramucci attacked Priebus in profane terms in an interview on Thursday, predicted he would soon be out of a job, and pledged to crack down on leaks that Scaramucci suspected had come from Priebus.

But what may have ultimately doomed Priebus is the failure of congressional Republicans to repeal Obamacare.

Priebus, former chairman of the Republican National Committee during last year’s presidential campaign, led the White House effort on Capitol Hill to get rid of Obamacare, and his fate was largely tied to that, a source close to the White House told NBC News.

“He failed,” the source said.