# Killing Pytest Agent Terminal doesn't actually end Pytest execution

**URL:** <https://forum.cursor.com/t/killing-pytest-agent-terminal-doesnt-actually-end-pytest-execution/172697>\
**Category:** Bug Reports\
**Tags:** terminal\
**Created:** [September 22, 2026, 7:09pm UTC](https://forum.cursor.com/t/killing-pytest-agent-terminal-doesnt-actually-end-pytest-execution/172697 "2026-09-22T19:09:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![J3TK](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@J3TK](https://forum.cursor.com/u/J3TK)\
**Post date:** [September 22, 2026, 7:09pm UTC](https://forum.cursor.com/t/killing-pytest-agent-terminal-doesnt-actually-end-pytest-execution/172697/1 "2026-09-22T19:09:21Z")

</div>

### 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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/colin/32/90452_2.png) [@Colin](https://forum.cursor.com/u/Colin)\
**Post date:** [September 22, 2026, 7:34pm UTC](https://forum.cursor.com/t/killing-pytest-agent-terminal-doesnt-actually-end-pytest-execution/172697/5 "2026-09-22T19:34:41Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [September 24, 2026, 7:34pm UTC](https://forum.cursor.com/t/killing-pytest-agent-terminal-doesnt-actually-end-pytest-execution/172697/7 "2026-09-24T19:34:57Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
