I wonder if we should write the inner loop as:

```c
    git_global_shutdown_fn cb = git__swap(git__shutdown_callbacks[pos - 1], NULL);
    if (cb != NULL)
        cb();
```

I think if two threads were accidentally concurrently calling `git__shutdown` that would make sure that each callback was only invoked once.