         )
         let metadataProvider = PackageIndexMetadataProvider(
             index: index,
-            alternative: GitHubPackageMetadataProvider(
-                configuration: .init(authTokens: collectionsConfiguration.authTokens),
-                observabilityScope: observabilityScope
+            alternativeContainer: (
+                provider: GitHubPackageMetadataProvider(
+                    configuration: .init(authTokens: collectionsConfiguration.authTokens),
+                    observabilityScope: observabilityScope
+                ),
+                managed: true
             )
         )
         

    }
}

struct PackageIndexMetadataProvider: PackageMetadataProvider {
    let index: PackageIndex
    let alternative: PackageMetadataProvider

    func get(
        identity: PackageIdentity,

            self.index.get(identity: identity, location: location, callback: callback)
        } else {
            self.alternative.get(identity: identity, location: location, callback: callback)
        }
    }
    
    func close() throws {
        guard self.alternativeContainer.managed else {
            return
        }
        if let alternative = self.alternative as? Closable {
            try alternative.close()
        }
    }
}
