Called when the connection is lost to the server.

def connectionLost(self, reason):
        """Called when the connection is lost to the server."""
        self.factory.loader.db.session.commit()
        if reactor.running:
            reactor.stop()