S&P 500, Nasdaq retreat as investors sell tech stocks