S&P 500, Nasdaq notch all-time closing highs ahead of Jackson Hole