The Hershey Trust for impoverished students has sold about $475 million in chocolate company stock, modestly diversifying the charity's chocolate-rich assets as changing consumption and retail trends are creating headwinds for the U.S. candy sector.

The deal allows the charitable trust to realign its portfolio after a run-up in Hershey Co. stock but also indicates that the trust is not looking for a merger or acquisition after rejecting the Mondelez International Inc. takeover offer last year.

Wall Street punished Hershey stock on the news on Thursday, with shares shedding 1.8 percent, or $1.92, and closing at $105.52.

The Hershey Trust, which includes a state-chartered bank that manages the $13.8 billion in charitable assets for the Milton Hershey School, said on its website after the market closed Wednesday that it had sold 1.5 million shares back to the Hershey Co. for $106 a share. The chocolate company separately announced the deal Wednesday evening.

The Hershey Trust also sold 3 million shares to Morgan Stanley but did not disclose the price for those shares.

The stock sales represented about 6 percent of the trust's $7.8 billion stake in the chocolate company. And the charity will retain 80 percent voting control over the Fortune 500 corporation.

"We are confident and firm supporters of the Hershey Co. and its management team as they successfully position the company for sustainable growth and value," said Velma Redmond, chairman of the Hershey Trust Co. board.

Milton and Catherine Hershey bequeathed the family fortune in the early 20th century to the trust to finance what was then the Hershey orphanage and trade school, now the Milton Hershey School. The institution for kindergarten through 12th grade — which has been plagued by infighting and disputes over its mission over the last two decades — is the richest private school in the United States.

The Hershey Co. rejected a takeover bid by Mondelez International Inc. for a reported $115 a share in 2016. Hershey and other legacy packaged-food companies, among them Campbell Soup, have experienced slower sales growth as consumers shop for healthier choices. Nestle, one of the world's largest global chocolate companies, said in June that it was considering a sale of its American candy business, the home of treats that include Gobstoppers, Nerds, and Butterfinger and Crunch bars, as demand for sweets has fallen off in the United States.

In February, Hershey itself announced a 15 percent cutback in its global workforce, eliminating about 2,700 workers, as it seeks to cut costs amid slow sales growth. The company also has said it will innovate in its retail packaging and over time cut calories in its single-sale candy bars.

"We see more downside than upside in the near term for [Hershey Co.] shares," Pablo Zuanic, analyst with Bala Cynwyd-based Susquehanna Financial Group, wrote in a note on Thursday. "We would not recommend owning the stock on the assumption the trust will consider radical strategic changes."

Even with the stock sale, roughly 50 percent of the trust's assets will be concentrated in Hershey Co. stock through both common and super-voting shares, according to data.

"Hershey Trust Co. has an active history of managing the investment portfolio on behalf of the Milton Hershey School Trust," Eric Henry, chief executive officer of the Hershey Trust, said in a statement. "The concentration of the Hershey Co. stock in our overall portfolio has increased over the years because of the exceptional performance of the Hershey Co. and the corresponding stock value."