Hungary will close its border with Croatia at midnight in an attempt to prevent migrants from entering the country, officials said Friday.

Hungarian Foreign Minister Peter Szijjarto said people would only be able to cross into the country through official border stations and submit asylum requests at two locations, Reuters reported. The country completed construction of a razor-wire barrier along the 220-mile border with Croatia this week.

More than 378,000 migrants and refugees bound for Europe have crossed into Hungary since the start of the year, fleeing war and poverty in their native countries, mostly in the Middle East. The vast majority of them are making their way westward to Germany, which has suspended the European Union’s usual rules for asylum-seekers specifically for Syrians fleeing that country’s civil war.

Hungary sealed its 110-mile border with Serbia with a similar fence last month, leaving thousands of migrants stranded. They went through Croatia instead, where the government transported them on buses and trains to Hungary’s border with Austria. With the Croatia border sealed, migrants will be forced to look for alternate routes, perhaps through Romania, which has so far not been a major transit country for them.

Hungary’s fence is a sobering symbol of the fractured and arduous European effort to handle the worst refugee crisis since World War II. On the opposite side of the spectrum, Germany, the preferred final destination of the majority of refugees, is operating under an open-door policy. Croatia, Serbia, and Romania, along with Western European nations, have criticized Hungary’s border policy. The European Union agreed last month on mandatory quotas to relocate 120,000 migrants across the continent. Hungary, Romania, Slovakia, and the Czech Republic voted against the plan, but they were overruled. Britain has been granted an exception to the quotas, but has promised to resettle 4,000 refugees this year and 20,000 over the next five—all from Syria.

This week, Hungarian Prime Minister Viktor Orban said he wants Greece—the biggest point of entry into Central Europe for refugees—to close off its borders, too. On Friday, EU leaders announced that Turkey had agreed to do more to stem the entry of migrants to Europe in exchange for looser visa restrictions and renewed talks about Turkey’s application to the bloc. But Turkey denied that a deal had been finalized.

There is some evidence Hungary’s border policy has worsened the crisis. Here’s what happened when refugees learned in August that Hungary was going to seal off its border with Serbia, from The New York Times:

Paradoxically, far from deterring the migrants, Hungary’s fence may actually be spurring them on. In a dozen or so fractured interviews this weekend, many Syrians, Afghans and others said that word of the fence had accelerated their race to get north before all of the Hungarian border with Serbia—almost 109 miles—is cordoned off, a goal that the Hungarians have set for Aug. 31.

Robert Lesmajster, a veteran of refugee aid organizations who greeted people in Serbia, told the Times: “They all want to go to Germany. Their ‘promised land.’… The Hungarian fence cannot stop them.”