function close(): \React\Promise\PromiseInterface {
        if($this->goingAway) {
            return $this->goingAway;
        }
        
        $deferred = new \React\Promise\Deferred();
        $this->goingAway = $deferred->promise();
        
        $closes = array();
        
        /** @var \Plasma\DriverInterface  $conn */
        foreach($this->connections->all() as $conn) {
            $closes[] = $conn->close();
            $this->connections->delete($conn);
        }
        
        /** @var \Plasma\DriverInterface  $conn */
        foreach($this->busyConnections->all() as $conn) {
            $closes[] = $conn->close();
            $this->busyConnections->delete($conn);
        }
        
        \React\Promise\all($closes)->then(array($deferred, 'resolve'), array($deferred, 'reject'));
        return $this->goingAway;
    }