But a day after the state sent its blistering letter to Southwest Key CEO Juan Sanchez, it became clear that any shutdown would create a tumultuous chain of events for federal and state regulators, who lack options for housing tens of thousands of unaccompanied children who cross the border every year.

“Shutting down the shelters would create a crisis for the federal Office of Refugee Resettlement, which is charged with housing children caught at the border,” said Maria Cancian, deputy assistant secretary for policy at the U.S. Department of Health and Human Services’ Administration for Children and Families from 2015 to 2016.

Southwest Key is the country’s largest operator of immigrant youth shelters, housing more than 5,000 children in Arizona, Texas and California. As many as 1,600 children currently reside in its Arizona facilities.

The Texas-based nonprofit has become an increasingly critical asset for the federal government as the number of children in its custody has reached record numbers — even as the Trump administration has ended the practice of separating children from their parents. Southwest Key has received more than $1.3 billion in federal grants and contracts for the shelters and other services in the past five years.

Arizona’s investigation showing the company has been lax in protecting children in its care highlights the government’s fraught reliance on shelter operators — and the power those operators have, even in the face of failures. The federal government desperately needs every shelter as tougher immigration policies have put the system near capacity, housing five times as many children as last summer. Former HHS officials said closing 13 shelters in Arizona at once would throw the system into chaos.

It would create a “humanitarian crisis,” said one former official, forcing federal officials to scramble to find safe, licensed housing with trained and vetted staff for 1,600 children.

Arizona launched its investigation of Southwest Key’s shelters after news reports raised questions about background checks and other issues. A ProPublica story in August detailed the charges against Levian Pacheco, a former Southwest Key employee who is accused of molesting eight boys at a Mesa shelter over an 11-month period. Pacheco, who is HIV-positive, went without a background check for nearly four months. He was convicted earlier this month of 10 sex offenses connected to the molestation.

In response to media attention and complaints, Arizona health officials reviewed records on background checks at every Southwest Key facility across the state. Of the 13 shelters, the state found two additional facilities also had problems with background checks. In mid-August the company agreed it would verify that all employees had complete background checks by mid-September.

Arizona health officials also found that Southwest Key hadn’t vetted all employees by interviewing their previous employers and hadn’t ensured all employee files contained proof of tuberculosis testing. At some facilities, officials discovered bedroom and bathroom doors missing and problems with the size of residents’ rooms.

In Wednesday’s letter, Dr. Cara Christ, the director of the Arizona Department of Health Services, told Sanchez that his organization had failed to comply with the mid-August agreement.

“Southwest Key’s lack of ability to deliver a simple report on the critical protections these children have against dangerous felons demonstrates an utter disregard for Arizona law,” Christ wrote.

Jeff Eller, a Southwest Key spokesman, said the nonprofit has requested a meeting with state health officials to discuss the matter. “We have apologized to DHS for missing the reporting deadline and are serious about ensuring that never happens again,” he said in a statement. Eller declined to comment on the substantive issues raised in Arizona’s investigation. The state’s move to revoke the licenses was first reported by Arizona media outlets.

Gov. Doug Ducey’s office said in an email on Thursday he expects licensed facilities to comply with the law or his administration will hold them accountable.

Federal HHS spokesman Kenneth Wolfe said in an email Thursday that the agency was reviewing the letter and working with the shelters and Ducey’s office “to get all of the facts regarding the Arizona Department of Health Services audit to determine the next step.”

Former federal officials said they anticipate HHS will step in to help negotiate an outcome between Southwest Key and Arizona that will allow the children to remain in the facilities. Even Arizona officials acknowledged that the letter represents the beginning of what would be a long process.

In Texas, which has 16 Southwest Key facilities housing about 3,700 children, state health officials say they are not aware of similar issues with Southwest Key.

The Texas’ Health and Human Services Commission said its “monitoring inspections have not produced evidence of a pattern of background check deficiencies within any SWK [Southwest Key] operation, nor any patterns of failure to comply with minimum standard training requirements.”

An official with California’s Department of Social Services said in June the agency re-inspected all known facilities used by the US Office of Refugee Resettlement — including those operated by Southwest Key — and found no licensing concerns. The dust-up comes as the number of immigrant youth in federal custody has continued to grow. Immigrant advocates and former health officials say the record population doesn’t appear to be due to an influx of children at the border, but to the fact that children are staying in the shelters nearly twice as long as in the past.

They attributed that to a Trump administration policy that requires health officials to share information with Immigration and Customs Enforcement to vet potential sponsors for children in the shelters. As a result, they said, many parents and relatives who have traditionally served as sponsors worry they’ll be turned over to ICE if they come forward.

Matthew Albence, who heads ICE’s Enforcement and Removal Operations, gave credence to that fear at a Senate hearing on Tuesday when he testified that ICE had arrested 41 people who either came forward as sponsors or lived with them.

“Close to 80 percent of the individuals that are either sponsors or household members of sponsors are here in the country illegally,” Albence said. “So we are continuing to pursue those individuals.”

Arizona’s move against Southwest Key is just the latest in a series of bad headlines for the nonprofit.

In addition to ProPublica’s reporting on Pacheco, two other cases involving abuse at other Southwest Key shelters in Arizona surfaced in July. An employee at a Southwest Key facility in Phoenix was arrested on allegations that he sexually abused a 14-year-old girl by kissing her and rubbing her breast and crotch, according to Phoenix news outlets. And The Nation reported in July that a 6-year-old girl, who had been separated from her mother, was allegedly fondled by a boy at a Southwest Key facility in Glendale in June.

At other Southwest Key facilities, police reports and call logs from the last five years detail dozens of runaways, inappropriate relationships with staff, sexual contact among kids, and allegations of molestation by employees, ProPublica found. In one case, a 46-year-old youth care worker in Tucson was convicted of groping a 15-year-old boy who had arrived in the United States five days earlier.

In response to each of these reports, a Southwest Key spokesman said the organization immediately reports any abuse claim to police, that it cooperates fully with all investigations and that it educates children in its care of their right to be free of abuse.

And in August, UnidosUS, formerly known as the National Council of La Raza, the nation’s largest Hispanic civil rights and advocacy organization, suspended its affiliation with Southwest Key.

Both UnidosUS and Arizona officials highlighted similar concerns about the Southwest Key officials’ attitude toward the scrutiny it is receiving. UnidosUS said the organization “failed to convey that it understands the gravity and magnitude of the situation” and had failed to apologize to the victims in its care.

In response to UnidosUs, Eller told the Austin American-Statesman in August that the company was disappointed in the group’s decision and said any insinuation that Southwest Key didn’t take allegations seriously was grossly incorrect.

A former HHS official with knowledge of how the refugee resettlement agency operates said the recent developments with Southwest Key raise serious questions about the organization’s ability to meet the government’s needs.

“It sounds like, based on their inability to respond or even communicate in a timely fashion that they have really significant internal operating challenges and that may or may not be indicative of the quality of care the children are receiving,” the former official said.

Nonetheless, other former officials said shuttering the facilities might not be in the best interest of the children. The state might have more effective options, such as increasing unannounced visits to shelters.

Claudia Flores, director of the International Human Rights Clinic at the University of Chicago Law School who has studied the conditions faced by immigrant youth at the border, highlighted the difficult position the federal government and Arizona are in with Southwest Key.

“It’s not a response to say we can’t shut down the facilities when there are reports of abuse taking place,” she said. “It’s really not the kids in these facilities that should be suffering.”