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