Three weeks after three teens allegedly raped a woman after fleeing a group home in Brooklyn, New York City has ended its multimillion-dollar contract with the nonprofit social services agency that ran the home.

The development, jointly announced Wednesday by the city and the agency, came after authorities uncovered management problems at other group homes operated by the organization, known as Boys Town.

Boys Town had signed a $6.4 million deal with the city to oversee troubled youngsters as part of an experimental program launched in 2012. The initiative, known as Close to Home, calls for juvenile offenders to be held in group homes rather than in the upstate youth prisons that had been plagued by violence and allegations of sexual abuse. The idea was that the children would be more effectively treated if they were kept nearer to their families and received therapeutic services in less restrictive settings. The program requires that the homes be locked and equipped with alarms.

Earlier this month, three 16-year-old boys from a Boys Town home in Park Slope were arrested and charged with beating, robbing and raping a woman in Manhattan’s Chinatown neighborhood. A worker at the home was later charged with having falsified records meant to show the boys were being properly accounted for and supervised. The arrests prompted Boys Town to immediately stop accepting new children at the Brooklyn residence.

According to an official briefed on that investigation, the city’s Administration for Children’s Services dispatched a team that conducted nine unannounced site visits in Boys Town’s four Close to Home facilities during the week immediately following the alleged rape.

“The results were troubling and revealed an inconsistent ability to comply with Close to Home requirements,” said the official, who was not authorized to speak by name about the investigation. “Supervisors were unable to ensure that the sites were secure and properly monitored.”

“Given the horrifying assault as well as Boys Town’s history of struggling to comply with Close to Home regulations, ACS and Boys Town jointly agreed to end the contract,” the official said.

In announcing the end of its contract with the city, Dan Daly, Boys Town’s director of youth care, defended the agency’s reputation.

“Boys Town has consistently been committed to serving youth in New York and across the country,” Daly said in a statement, adding that the agency will continue to provide other services in the city. “We have decided to shift our work toward what we do best.”

In the same statement, Gladys Carrión, commissioner of ACS, voiced support for the agency.

“New York City has a long standing partnership with Boys Town. We appreciate all of Boys Town’s hard work,” she said.

Boys Town is the third nonprofit agency to end its Close to Home contract with the city in the two years the program has been underway. In June 2013, a 17-year-old ran away from a Staten Island home and allegedly stabbed a man to death in Queens. The home, run by the nonprofit New York Foundling, was subsequently closed after New York Foundling withdrew from its contract with the city.

A spokesperson for New York Foundling would not respond to questions on the matter, pointing instead to a press statement issued at the time.

“At this time, we have made a determination that the fit of the Close to Home program with our other community and evidence-based programs is not optimal, and so we have voluntarily decided to end our participation in the program,” said Bill Baccaglini, the president and chief of executive of New York Foundling. “In no way should the recent tragic incident be interpreted as an indictment of the Close to Home program, a very smart and most welcome policy shift in the treatment of juvenile delinquents.”

Another home on Staten Island run by St. Vincent’s Services agreed to have its city contract revoked due to issues with runaways. A spokesperson for St. Vincent’s did not immediately respond to comment for this article.

The Boys Town home in Brooklyn had come under scrutiny from ACS before the alleged rape this month. In January 2014, children from the facility were running away and getting involved in violent incidents, prompting ACS to put the home under what is known as “heightened monitoring status,” wherein inspectors visit the home more regularly and attempt to tighten security measures.

The city official said that Boys Town satisfied the regulators’ requests sufficiently enough to remove the home from the increased monitoring.

Boys Town serves more than 1,700 children and families involved in the New York City criminal and family justice system every year.

Following the arrests earlier this month, the city Department of Investigation said it would conduct a broader investigation of the Close to Home program. A person familiar with the evolving investigation said DOI had recently directed officials at various Close to Home facilities to preserve any and all documentation concerning their operations.

ProPublica reported two weeks ago that runaways from Close to Home facilities had gone down of late. In 2013, there were 740 AWOLs, while in 2014 there were 363. In that time span, the program increased the number of children it served from 583 to 707.

Clarification: An earlier version of this article reported that a group home for troubled children in New York was shut down by the city’s Administration for Children’s Services and its contract with the city terminated after a boy from the home killed a man in Queens. ACS has amended the timeline of events: The home, run by New York Foundling, was closed after the agency’s contract with the city was terminated.