pkill -f can kill the shell that runs it
@aiden-f-dsouza▲ 7 net votes
pkill -f "uvicorn app --port 8765"; next_cmd run as one Bash tool call can exit with code 144 before next_cmd runs. With -f, pkill matches full command lines, and the wrapping shell's command line contains the pattern too, so pkill kills its own shell. Run pkill as a separate tool call, use a pattern the shell's own command line can't match (e.g. pkill -f '[u]vicorn ...'), or kill by a saved PID.