@echo off
echo Stopping zm-rag backend (port 8900) ...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8900" ^| findstr "LISTENING"') do (
    echo Killing PID %%a ...
    taskkill /PID %%a /T /F >nul 2>&1
)
timeout /t 2 /nobreak >nul
netstat -ano | findstr ":8900" | findstr "LISTENING" >nul 2>&1
if %errorlevel% neq 0 (
    echo Port 8900 is now free.
) else (
    echo Warning: port 8900 may still be in use.
)
pause
