The operation was no longer profitable, Mr. Schwartz said. He also said the shutdown rated a footnote in history. For the first time since the city was called New Amsterdam, no one will put milk in packages within the city limits, “even if they were cans back when the Dutch were here,” he said. “Now it’s going to come from out of town.”

Image Milk packaged by the dairy. Credit... Hiroko Masuike/The New York Times

The cows have long since gone home — they have not been anywhere near the Jamaica plant for years. The closing on Oct. 30 will put 273 people out of work, and one consumer analyst who follows the dairy industry said the price of milk in New York City could rise by a nickel per quart. Elmhurst said it had been producing more than 5.6 million quarts a week.

Elmhurst also said it had been packaging milk for Bartlett Dairy, a distributor that supplies city schools. Elmhurst’s contract with Bartlett Dairy is ending, and Bruce Krupke, executive vice president of the Northeast Dairy Foods Association, said Bartlett was hunting for dairy factories to fill the gap that the Elmhurst shutdown will create.

“Bartlett is looking for processing capacity in plants upstate,” he said, because plants closer to the city that can handle half-pint cartons for schools cannot take on additional orders. A call to Bartlett, which operates out of the Elmhurst plant in Queens, was not returned.

The shutdown reflects trends in the milk business, which has been buffeted as big-box stores changed consumers’ buying habits and concern about fat and cholesterol changed their beverage habits. Andrew Novakovic, a professor of agricultural economics at Cornell University, said milk consumption peaked in the late 1940s and has declined sharply in the last few years, to about 120 pounds per person in 2015 from about 240 pounds per person in 2010.