The Market Basket supermarket chain has agreed to sell to a majority stake to former boss Arthur T. Demoulas, ending…