Don't reset flag while command is running because it makes end-less loop if command generate files.