Close the global http client after `ensurePubspecResolved` (#4199)

diff --git a/lib/pub.dart b/lib/pub.dart
index 532aad1..c12d714 100644
--- a/lib/pub.dart
+++ b/lib/pub.dart
@@ -6,6 +6,7 @@
 
 import 'src/entrypoint.dart';
 import 'src/exceptions.dart';
+import 'src/http.dart';
 import 'src/pub_embeddable_command.dart';
 import 'src/system_cache.dart';
 
@@ -52,6 +53,11 @@
     );
   } on ApplicationException catch (e) {
     throw ResolutionFailedException._(e.toString());
+  } finally {
+    // TODO(https://github.com/dart-lang/pub/issues/4200)
+    // This is a bit of a hack.
+    // We should most likely take a client here.
+    globalHttpClient.close();
   }
 }