S&P closes at new all-time high; Nasdaq records biggest gain in a year