added thread termination