correct thread termination