fixed improper thread termination as a result of previous commit