Middleware to gracefully shutdown Express apss