code: function deactivate () {
      if (!_active || _deactivating) return node
      debug('deactivating')
  
      if (external) {
        _active = false
        _subConnection.disconnect()
        _pubConnection.disconnect()
        node.emit('deactivated')
      } else {
        _deactivating = true
        let ensuredMaster = Promise.resolve()
  
        const isMaster = _subConnection.master && _subConnection.master.name === _name
  
        if (isMaster) {
          debug(`I'm the master node. I will try to elect another master before disconnecting.`)
  
          let advertiseId = `zz-zzzzzzzz-${_id}`
          ensuredMaster = _masterResolver
                          .resolve(advertiseId)
                          .then(master => {
                            debug(`successfully elected a new master: ${master.name}`)
                            try {
                              _masterBroker.signalNewMaster(master)
                            } catch (e) {
                              console.log(e)
                            }
                          })
                          .catch(() => {
                            debug(`failed to elect a new master. Disconnecting anyway.`)
                          })
        }
  
        ensuredMaster
        .then(() => {
          _subConnection.disconnect()
          _pubConnection.disconnect()
          _masterResolver.unbind()
          let timeout = isMaster ? 1000 : 1
          setTimeout(() => {
            debug('deactivated')
            node.emit('deactivated')
            _masterBroker.unbind()
          }, timeout)
        })
      }
  
      return node
    }
docs: Starts the node's deactivation routine
  @return {object} node instance