async close (code, reason) {
    if (!this._isOpen || this._ws === null) {
      throw new Error('not open')
    }

    debug('disconnecting...')

    return new Promise((resolve) => {
      this._ws.once('close', () => {
        this._isOpen = false
        this._ws = null

        debug('disconnected')
        resolve()
      })

      if (!this._isClosing) {
        this._isClosing = true
        this._ws.close(code, reason)
      }
    })
  }
Closes the active connection. If there is none, rejects with a promise.
Resolves on success

@param {number} code - passed to ws
@param {string} reason - passed to ws
@returns {Promise} p