             let log = try self.make(Logger.self)
             log.warning("Debug build mode detected while configured for release environment: \(environment.name).")
             log.info("Compile your application with `-c release` to enable code optimizations.")
+        }
+    }
+    
+    deinit {
+        eventLoopGroup.shutdownGracefully {
+            if let error = $0 {
+                print("[Vapor] shutting down app event loop: \(error)")
+            }
         }
     }
 

        self.services = services
        self.serviceCache = .init()
        self.extend = Extend()
        self.eventLoop = MultiThreadedEventLoopGroup(numThreads: 1).next()
        self.router = try self.make(Router.self, for: Application.self)

        // boot all service providers

    /// See ServiceCacheable.serviceCache
    public let serviceCache: ServiceCache

    /// The event loop group that we derive the event loop below from, so we can close it in `deinit`
    private var eventLoopGroup: EventLoopGroup = MultiThreadedEventLoopGroup(numThreads: 1)

    /// See Worker.eventLoop
    public var eventLoop: EventLoop

