close () {
    if (this._closingPromise === null) {
      this._closingPromise = new Promise((resolve, reject) => {
        this._clearConnectionTimeout()
        if (this._ws && this._ws.readyState !== WS_CLOSED) {
          this._open = false
          this.stopReceiveTimeout()
          this._ws.onclose = () => {
            resolve()
          }
          this._ws.close()
        } else {
          resolve()
        }
      })
    }

    return this._closingPromise
  }
Close the connection
@returns {Promise} A promise that will be resolved after channel is closed