@asm582 I think the issue here is that you are intending to kill the program, but you’re actually stopping it instead.
In general, ctrl+z sends a SIGSTOP to the program, which only pauses it, so the tasks remain because you could always unpause the program by running kill -SIGCONT <pid>
.
I think what you’re looking for is ctrl+c which will actually kill the process and trigger the cleanup (SIGTERM).