Hungary will quit a U.N. migration pact before its final approval, it said on Wednesday, calling the agreement a “threat to the world”.