In short, you cannot. Or rather, you should not. Never, under any circumstances.
There is no way that thread A knows the exact state of thread B when A kills B. If B holds any locks either in the middle of a system call or calls the system structure when A kills it, then the resulting state of your application will be non-deterministic.
Actually - this will be somewhat deterministic in the sense that you are largely guaranteed that a failure will occur in the near future.
If you need to terminate thread B, you need to do this in a controlled way. The most common way is to have a flag cancelor method that can be set / called. stream B then needs to periodically check this flag or check whether the method has been called, clear everything it does, and then exit.
That is, you will have to change the logic in thread B to support this.