The end of Krispy Kreme’s doughnut partnership with McDonald’s weighed on the company’s second-quarter results.