public void fireSessionDestroyed(IoSession session) {
        SocketAddress serviceAddress = session.getServiceAddress();

        boolean lastSession = false;
        synchronized (managedSessions) {
            // Get the session set.
            Set<IoSession> sessions = managedSessions.get(serviceAddress);
            // Ignore if unknown.
            if (sessions == null) {
                return;
            }
    
            sessions.remove(session);
    
            // Try to remove the remaining empty session set after removal.
            if (sessions.isEmpty()) {
                lastSession = managedSessions.remove(serviceAddress, sessions);
            }
        }

        // Fire session events.
        session.getFilterChain().fireSessionClosed(session);

        // Fire listener events.
        try {
            for (IoServiceListener listener : listeners) {
                try {
                    listener.sessionDestroyed(session);
                } catch (Throwable e) {
                    ExceptionMonitor.getInstance().exceptionCaught(e);
                }
            }
        } finally {
            // Fire a virtual service deactivation event for the last session of the connector.
            //TODO double-check that this is *STILL* the last session. May not be the case
            if (session.getService() instanceof IoConnector && lastSession) {
                fireServiceDeactivated(session.getService(), session
                        .getServiceAddress(), session.getHandler(), session
                        .getServiceConfig());
            }
        }
    }