S&P 500 ends down slightly after flirting with record levels again