“In effect, it felt like we were being punished,” Mr. Heilman said. “But the punishment turned out to be a blessing in disguise. This is really a case of perspective.”

Although aggressive testing and confinement orders have shown promise in New Rochelle and elsewhere, including in South Korea, it may be too late to employ similar strategies in places like New York City, where the number of positive cases has overwhelmed the city’s ability to offer tests broadly or to trace the contacts of those infected.

The lawyer at the center of the New Rochelle cluster, Lawrence Garbuz, 50, fell ill on about Feb. 27, and was confirmed on March 2 to have the coronavirus. Health officials began to trace his contacts and soon found more infections.

State and Westchester County health officials ordered the closure of the synagogue, and on March 3 ordered quarantines for the more than 100 families that were exposed to Mr. Garbuz at a funeral and a bat mitzvah in late February. As more synagogue members became infected, those who came in contact with them were also quarantined.

State and local health investigators also used contact-tracing techniques to track down people who were exposed to Mr. Garbuz, including workers at NewYork-Presbyterian Lawrence Hospital in Bronxville, N.Y., where Mr. Garbuz was initially hospitalized.

The containment zone in New Rochelle began on March 12; it was a one-mile radius, with Young Israel at its epicenter, that was to last for 14 days. The order did not close streets or prevent people from leaving, but it banned gatherings of over 500 and closed schools, houses of worships and other large gathering spaces within the zone.

Members of the New York State National Guard were called in to deliver meals to people stuck in their homes, and to deep-clean communal buildings.