US stocks change course to end lower, mired by rating downgrade