Gen. Austin S. Miller is leaving as the United States prepares to end its two-decade war in Afghanistan and Taliban fighters sweep across much of the country.