docs: def finalize(self):
          """Shutdown the library and clean up the model.
  
          Note that the Fortran library's cleanup code is not up to snuff yet,
          so the cleanup is not perfect. Note also that the working directory is
          changed back to the original one.
  
          """
          self.library.finalize.argtypes = []
          self.library.finalize.restype = c_int
          ierr = wrap(self.library.finalize)()
          # always go back to previous directory
          logger.info('cd {}'.format(self.original_dir))
          # This one doesn't work.
          os.chdir(self.original_dir)
          if ierr:
              errormsg = "Finalizing model {engine} failed with exit code {code}"
              raise RuntimeError(errormsg.format(engine=self.engine, code=ierr))