Fixed possible crash when closing externaloutput