US stocks end mixed ahead of midterms