ISIS-533: keep flushing until no more commands to flush