The evening light was still pouring through the windows of his Minneapolis hotel room when an exhausted Douglas Pyle collapsed on the bed and fell into a 14-hour slumber.

It was the first time in 18 months that Pyle, 49, who is homeless, slept in a bed in a private room with a locked door, and without fear that someone would roust him at night or steal his few belongings.

"It felt like I was sleeping on a cloud," Pyle said the next day. "The best part is, I can face the world with a clear mind."

Pyle is among about 540 homeless adults with underlying health problems who have been moved out of shelters and into four local hotels, as Hennepin County and Minnesota health officials race to prevent the sort of large-scale COVID-19 outbreaks that have devastated homeless populations in other cities, including Boston, New York and San Francisco. Spurred by the pandemic, the massive and unprecedented effort has reduced dangerous crowding by more than 50% at the county's largest shelters, which are considered fertile territory for the deadly virus to spread.

In early March, homeless shelters moved swiftly to employ physical distancing measures where possible, and to screen everyone entering the facilities for fevers. But as the crisis has deepened, and the virus attacked growing numbers of area homeless people, those measures were seen as inadequate.

Statewide, there are 41 residents of homeless shelters who have tested positive, according to state health officials. One by one, homeless adults who were considered especially vulnerable to the virus because of their age or underlying health problems have been moved to hotel rooms.

So far, Hennepin County has spent $4.3 million on the relocation effort, and it projects monthly ongoing costs of $1.6 million to house, staff and provide meals for those under quarantine in area hotels. Yet county officials maintain that the cost of leasing hotel rooms is a fraction of the potential expense of treating dozens of homeless people in area hospitals and intensive care units if a broad outbreak occurred within the shelter system.

"The idea is that we're trying to save lives and keep the virus from ripping through this vulnerable population," said Hennepin County Commissioner Mike Opat, who volunteered at one of the hotels last week.

The emergency effort was designed to shield people from a fast-moving virus, but officials hope the initiative will have a more lasting effect. By removing people from the often chaotic atmosphere of shelters, officials hope they will be able to better connect them to housing, medical care and other social services. Already, Hennepin County outreach workers have begun moving small numbers of people from hotel rooms into more stable housing.

"Once you extract someone out of that survival mode, and you create a new normal, they recognize that they don't want to go back to a shelter," said Christine Michels, director of housing stability and opportunity at Catholic Charities of St. Paul and Minneapolis. "We can use this situation as traction to propel people toward permanent housing."

David Hewitt, director of Hennepin County's Office to End Homelessness, agreed. "People still want their own homes even when they're in a hotel room," he said.

A recent study of homeless shelters in four major American cities confirmed what many public health experts had warned: Once coronavirus clusters develop in congested shelters, they are difficult to contain.

In San Francisco, two-thirds of residents at a large shelter tested positive for COVID-19, the respiratory illness caused by the virus. And more than a third of those tested at Boston's largest homeless shelter, the Pine Street Inn, tested positive. Out of nearly 1,200 shelter residents tested in four cities, 25% tested positive for the coronavirus, according to the study by the Centers for Disease Control and Prevention.

As he walked through the cramped sleeping quarters of the Higher Ground shelter in Minneapolis, Catholic Charities Chief Executive Tim Marx said "it's a miracle" that a cluster of infections had not spread at the 260-bed facility. Only a thin plastic sheet separates many of the bunks, where people sleep close enough to hear each other breathing. About a dozen mats lay strewn about the floor; residents stake out any open space to avoid getting infected.

"Social distancing and shelter have become an oxymoron," Marx said. "It's really critical because you can see people on top of each other and right next to each other."

For Pyle, the move to a hotel room offered a potential turning point in his long struggle to emerge from homelessness.

Pyle said a prolonged bout with alcoholism cost him his job and the room he was renting in south Minneapolis. Once homeless, he bounced from one shelter to the next, while occasionally sleeping under building entrances downtown or on the light-rail line when the shelters were full. There were nights when it was too cold to sleep outside, Pyle said, and he would wander the streets until dawn.

"People don't realize, but it's very tiresome being homeless," he said. "You've always got to be on the move and there's no place to rest."

Yet Pyle had begun to turn his life around earlier this year. He landed a full-time job as a cook at the Fillmore Minneapolis, the new concert hall downtown, and began saving money for an apartment while still staying in shelters. Then the coronavirus hit and downtown Minneapolis became a ghost town. Like millions of other Americans, Pyle was suddenly thrown out of work.

"I don't feel self-pity, but I'm mad at myself and I'm mad at the choices I've made," he said.

On a cloudy morning last week, Pyle looked relieved as he walked into a sixth-floor downtown Minneapolis hotel room with a king-size bed, bathroom, television and small refrigerator.

As he sat on the edge of the bed, a social worker calmly explained the rules of his hotel stay — no smoking, no visitors; and a protective mask must be worn while walking around the hotel. After she was finished, Pyle grinned and said, "Don't worry, you won't have any problems with me.

"Believe me," he added, looking around the room. "This is perfect."