def METHOD_NAME(self, result):
    if self.output is not None and self.output is not sys.__stdout__:
        self.output.close()
    global PLUGIN_INSTANCE
    PLUGIN_INSTANCE = self.old_plugin_instance