stop thread when not in use