Avoids a brief window where other threads see an empty os.environ during profile job teardown. Idea from PR #19958.