Ensure that the internal thread exit handler always succeeds