China’s economic miracle is ending, leaving President Xi Jinping with a challenge none of his predecessors faced: how to govern after the boom.