def _register_atexit_handler(self):
        """Can be called to register a cleanup handler on interpreter exit.

        The APIs can register this to ensures the close() method is called
        on interpreter shutdown."""
        atexit.register(self.close)