Hungary's president signed a constitutional amendment into law on Saturday that ends his term in office, bringing to a close a dispute between him and the country's new government that was seeking to oust him as part of a purge of officials appointed during the tenure of Viktor Orban.