Fix a bug in MultiOutput.
Fix a potential race condition on shutdown.