US stocks close mixed as tech rally cools after a brief S&P 500 surge past 5,100