implementing teardown of threads correctly - previous commit was untested