Possible solution to the threads termination problem