Fix the thread removal/cancel process