A late slide erases gains for US indexes