How to simplify a discord bot remote tool
This depends on the nature and purpose of the process.
For example, you might schedule your process as a coroutine, and cancel its execution with Future.cancel: https://docs.python.org/3/library/asyncio-future.html#asyncio.Future.cancel
Your process killing method is aggressive and quite risky, some more context around why you're cancelling processes and the nature of the processes would be useful for providing answers.