Prevent hang on exit.

If there are any outputs configured, trying to close them results
in endless loop due to missing check.