S&P 500, Nasdaq close Q2 at record highs owing to tariff uncertainty