Flatten not executed timely

Hi, how come Flatten didn’t execute the market orders immediately? I had only 2 MES contracts open at the time. I kept getting Failure notifications which eventually closed my 2 positions but it also entered me into 2 new contracts which I tried to flatten again but I kept getting more failure notifications. This has occurred multiple times already.