Americans made plans to leave Brazil on Tuesday, hours before a U.S. ban on arrivals from the country was due to take effect.

U.S. citizens and green-card holders are exempt from the prohibition, intended to slow the spread of the coronavirus from Latin America’s hardest-hit country. But foreigners in Brazil have struggled to leave the country in recent weeks. The State Department on Tuesday advised all Americans who wished to leave to do so immediately.

Jennifer Ribachonek had been scheduled to return to the United States on Friday to care for her parents. Both are set to undergo surgery next month. But her Latam Arlines flight was canceled shortly after the White House announced the travel ban on Sunday.

“They don’t have the capacity to care for each other,” said Ribachonek, a teacher at an international school in São Paulo. She said her parents had hoped to see their grandchildren before their surgeries. “Stuff like that just gives them something to look forward to,” she said. “It would be great to get back.”

Brazil has reported nearly 375,000 cases of the coronavirus, second in the world only to the United States, and more than 23,000 deaths, a number widely believed to be an undercount.

On Monday, for the first time during the pandemic, more people died in Brazil than in the United States. The World Health Organization predicted at least 88,000 deaths in Brazil by August.

“Brazil is having some trouble, no question about it,” President Trump told reporters last week. “I don’t want people coming in here and infecting our people.”

The new restrictions bar foreigners who have been in Brazil during the previous 14 days from entering the United States. The ban was due to start Thursday but was moved forward to 11:59 p.m. Tuesday. It will remain in effect until Trump terminates it.

“We are advising U.S. citizens who wish to return to the United States to do so immediately,” a consular official who identified himself as Antonio said during a virtual town hall organized by the U.S. Embassy in Brasília. The embassy declined to provide his full name.

“Nobody knows what is going to happen tomorrow,” the official said. “As this crisis has unfolded, things have developed very quickly. That being said, if returning to the U.S. is something that you and your family want to do, our official advice is to do it now. Now means as soon as possible. Now means now.”

Commercial flights from São Paulo and Campinas were still available on Tuesday. Consular officials said they did not anticipate scheduling repatriation flights.

Brazil imposed travel restrictions against foreigners, including Americans, in March. Flights between the two countries, and throughout Latin America, have been sharply limited. Latam, based in Santiago, Chile, the region’s largest airline, filed for Chapter 11 bankruptcy protection on Tuesday.

Anne-Sophie von Heyden, an American who lives in São Paulo with her husband and 2-year-old daughter, has been trying to visit her parents in the United States since March, but her flights keep getting canceled. When the travel ban was announced, she decided to postpone her trip.

“It was a big blow,” she said. “Everything that we are going through makes me want to see my family more. I know that I can get into the United States, but I don’t know how hard it will be to get a flight or how easy it would be to come back to Brazil.”

As the death toll in Brazil has mounted, foreigners have tried to flee. Venezuelan and Colombians camped out on makeshift beds in São Paulo’s Guarulhos International Airport, waiting to board government-chartered flights home.

Cases and deaths have soared in Brazil as the virus plows through slums and into regions with limited access to health care. The government response, meanwhile, has been uneven. President Jair Bolsonaro has dismissed the virus as a “little flu” and called for people to get back to work, alienating former allies and leaving state governors to impose lockdowns.

Bolsonaro is on his third health minister since the country reported its first case in February. On Sunday, the president walked into a crowd of supporters at a rally in Brasilia. Without wearing a mask, he picked up a child and waved as supporters cheered.

Carol Morello in Washington contributed to this report.