Major stock indexes closed lower Tuesday after the benchmark S&P 500 and the tech-heavy Nasdaq hit new intraday records, while safe-haven gold crossed $4,000 an ounce for the first time.