The S&P 500 and the Nasdaq Composite erased their earlier gains to end the day on a down note.