diff --git a/test/OpenTelemetry.Tests/Shared/TestHttpServer.cs b/test/OpenTelemetry.Tests/Shared/TestHttpServer.cs index 1f56b2d76af..921502f6f97 100644 --- a/test/OpenTelemetry.Tests/Shared/TestHttpServer.cs +++ b/test/OpenTelemetry.Tests/Shared/TestHttpServer.cs @@ -100,7 +100,8 @@ public void Dispose() { try { - this.listener?.Stop(); + this.listener.Close(); + this.httpListenerTask?.Wait(); } catch (ObjectDisposedException) {