def close(self):
        """ Close the runtime, or kill it if the process does not
        respond. Note that closing does not work when the runtime is a
        browser, because we need a process handle.
        """
        if self._proc is None:
            return
        # Terminate, wait for a bit, kill
        self._proc.we_closed_it = True
        if self._proc.poll() is None:
            if self._proc.stdin:  # pragma: no cover
                self._proc.stdin.close()
            self._proc.terminate()
            timeout = time.time() + 0.25
            while time.time() < timeout:
                time.sleep(0.02)
                if self._proc.poll() is not None:
                    break
            else:  # pragma: no cover
                self._proc.kill()
        # Discart process
        self._proc = None
dataset/ETHPy150Open zoofIO/flexx/flexx/webruntime/common.py/BaseRuntime.close/original