Leaking file handles when pack cache is rebuilt

`PackBasedObjectStore` maintains a cache of the packs of the repository, and automatically refreshes it when it becomes stale (for example, after a push). Unfortunately, it doesn't close the previously opened packs when doing so.

This results in a leak of file handles, ultimately leading to the process hitting its open file handles limit.