def _finalize(self): sys.stdout = sys.__stdout__ logging.root.removeHandler(self._log_handler) self._log_handler.close() logger.info('Jupyter window finalized successfully')