The United States and Canada agreed to close their 5,500-mile border to nonessential traffic Wednesday, a drastic measure that officials hope will help stanch the spread of the novel coronavirus in both countries.

President Trump and Canadian Prime Minister Justin Trudeau decided to close the border Wednesday morning, Trudeau said at a news conference. People will no longer be able to traverse between the two countries for recreation and tourism, Trudeau said. It was not clear when the border would reopen.

“In both our countries we’re encouraging people to stay home,” Trudeau said. “We’re telling citizens not to visit their neighbors unless they absolutely have to. Well, this collaborative and reciprocal measure is an extension of that prudent approach.”

Trudeau spoke after Trump tweeted the plan earlier Wednesday.

Trudeau and Vice President Pence said essential travel, including for employees who live on one side of the border and work on the other, will continue. Trade and trucking will not be affected.

Pence said at a White House news conference that the closure was decided after “mutual discussion” between the two governments. The Department of Homeland Security will ensure that it remains closed to nonessential traffic, Pence said, while ensuring critical personnel and goods still enter the United States.

In 2018, goods and services trade amounted to an estimated $718.5 billion, according to U.S. figures.

“Our governments recognize that it is critical that we preserve supply chains between both countries,” Trudeau said, to “ensure food, fuel and lifesaving medicines” are able to move between the United States and Canada.

Trudeau also announced a $27 billion program to directly support Canadian families and businesses affected by the virus, and an additional $55 billion in aid through tax deferrals.

Trudeau spoke in Ottawa, where he is working in isolation as his wife, Sophie, recovers from covid-19, the disease caused by the virus.

Canada has confirmed around 650 cases of the coronavirus, according to a count kept by Johns Hopkins University. At least eight people have died. The United States has confirmed more than 7,000 cases, with cases in all 50 states and the District of Columbia. More than 110 people have died.

Trudeau announced the closure of Canada’s borders to most travelers Monday, but exempted U.S. citizens, Canadian citizens and permanent residents.

The closure will have a major impact on one of the world’s busiest border crossings, where people travel back and forth each day for work, to see family, or to shop or dine.

U.S. residents spend billions in Canada every year, and every month millions of vehicles traverse the border.

The Detroit-Windsor Tunnel, which 4.2 million vehicles used in 2019 to shuttle between downtown Detroit and Windsor, Ontario, will close to nonessential traffic. Many health care workers in Detroit live in Canada.

In Derby Line, Vt., where the Haskell Free Library and Opera House sits on top of the border — half of the building is in Canada, the other half in the United States — the closure will mean that people cannot grab a pizza in Canada and bring it home to Vermont, and that family members will be unable to pop across the border and say hello. For residents there, Canada is the same street: Main Street in Derby Line turns into Main Street in Stanstead, Quebec.

Ed Jenness, 70, lives a half-mile from the Canadian border in Derby Line. His wife’s family lives just across the border, and the couple enjoys going out to dinner in Sherbrooke, Quebec, about an hour away. Some people go to church in Canada, he said, and won’t be able to do so Sunday.

“There will be a trickle-down, and we will feel it. Our economy will go to hell,” he said. “And up here in northern Vermont, we don’t have much of an economy.”

In Blaine, Wash., which abuts White Rock, British Columbia, public officials and business owners braced for the impending restrictions at the Peace Arch, the third-busiest U.S.-Canada border crossing.

Blaine has a thriving cottage industry of mailbox stores for Canadians who take advantage of cheaper U.S. prices on e-commerce goods. Customers have already stopped coming, said one employee.

There is also a concern that critical business could get stopped at the border there. Health-care workers cross the border each day, and contractors who service medical equipment, including ventilators, work in both countries, said Matt Morrison, CEO of the Pacific NorthWest Economic Region, which in 2010 prepared plans for a biohazard event that flagged a more restrictive border-crossing as a potential hurdle for the region to manage a pandemic.

“I’m very concerned about any border guards’ ability to assess essential or critical personnel or services,” he said.

Greg Scruggs in Seattle contributed to this report.