Stocks end lower as S&P posts fourth straight decline