added correct threads termination
minor fix