def stop(self):
        """Stop the server if it's running."""
        # Try to stop process from PID file
        pid = self._manage_pid_file("read")
        if pid:
            try:
                process = psutil.Process(pid)
                try:
                    os.killpg(os.getpgid(process.pid), signal.SIGTERM)
                    process.wait(timeout=5)
                except Exception:
                    os.killpg(os.getpgid(process.pid), signal.SIGKILL)
            except Exception:
                pass

        # Try to stop process from instance variable
        if self._process:
            try:
                self._process.terminate()
                self._process.wait(timeout=5)
            except Exception:
                if self._process.poll() is None:
                    self._process.kill()

        self._process = None
        self._manage_pid_file("cleanup")
Stop the server if it's running.
src/upsonic/server_manager.py