The problem is that the system call is waiting for the end of B. That is named "blocking call". To avoid it you must use a non-blocking or async call.
Because your operating system is missing I take two guesses:
On Windows you need the handle and end the process with TerminateThread.
On Linux you can use the
kill command, if you have the pid of the process.