@Override
    public Future<WebServer> stop() {
        FutureTask<WebServer> future = new FutureTask<WebServer>(new Callable<WebServer>() {
            @Override
            public WebServer call() throws Exception {
                if (channel != null) {
                    channel.close();
                }
                if (connectionTrackingHandler != null) {
                    connectionTrackingHandler.closeAllConnections();
                    connectionTrackingHandler = null;
                }
                if (bootstrap != null) {
                    bootstrap.releaseExternalResources();
                }

                // shut down all services & give them a chance to terminate
                for (ExecutorService executorService : executorServices) {
                    shutdownAndAwaitTermination(executorService);
                }

                bootstrap = null;

                if (channel != null) {
                    channel.getCloseFuture().await();
                }

                return NettyWebServer.this;
            }
        });
        // don't use Executor here - it's just another resource we need to manage -
        // thread creation on shutdown should be fine
        final Thread thread = new Thread(future, "WEBBIT-SHUTDOW-THREAD");
        thread.start();
        return future;
    }