Killing Pytest Agent Terminal doesn't actually end Pytest execution

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Was developing and running a Pytest test suite with agent chat and agent terminal. Suite takes around 90 minutes so when I ran into issues, I was just killing the agent terminal to quickly fix and rerun. Agent acknowledged the terminal was killed in chat each time. Terminal disappeared from screen. Nonethless, I could tell the “killed” pytest runs were still executing in the background due to interaction with front end and hardware-in-the-loop, therefore interrupting my development.

Steps to Reproduce

Run Pytest suite
Kill terminal

Expected Behavior

Pytest suite that was running stops when terminal is killed

Operating System

Windows 10/11

Version Information

Cursor 3.21.16

For AI issues: which model did you use?

Grok 4.7 High (Probably not relevant)

Does this stop you from using Cursor

Yes - Cursor is unusable

Hey @J3TK, thanks for the report!

You’re right. On Windows, stopping or closing an agent terminal currently ends only the outer PowerShell process, so a long pytest run it started (and anything pytest launched) can keep going in the background. A fix that stops the whole process tree is already done and will ship in an upcoming Cursor update (3.22)

In the meantime, you can clean up leftover runs by pasting this into a PowerShell window:

Get-CimInstance Win32_Process -Filter "Name='python.exe' OR Name='pytest.exe'" | Where-Object { $_.CommandLine -like '*pytest*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force }

For the 90-minute suite, you could also run pytest yourself in a regular terminal tab (Terminal → New Terminal). Stopping it there with Ctrl+C or the trash icon should end the whole run.