A wave of closures is reshaping the grocery industry as retailers cut costs, adapt to competition, and adjust to shifting demand.