John Kelly took over as chief of staff six months into the Trump presidency, and he initially helped bring military discipline to a sometimes chaotic White House.