Stocks end mixed as afternoon rally cools