S&P 500, Nasdaq post highest closing of year