Cancel thread handling