US stock markets saw the Nasdaq and S&P 500 reverse earlier gains to close lower, while the Dow Jones Industrial Average pared its advance to finish nearly flat.