Nasdaq and S&P 500 end down after hitting record highs