Cleanup dedicated thread after an exception.