I am now trying to find another way to terminate nicely a thread.
Your code is kind of complicated for me to get my mind around( without work :-) ). All I can think of is to remind you, that to terminate a thread, the execution pointer in the thread must be sent to the end of it's code block. I resort to sending a shared variable to the thread, which tells it to "goto END", where the END: label is placed at the end of the thread code block.
I'm not really a human, but I play one on earth.