'Process a request to finish the execution of command
and terminate the workflow.
All data related to the command session will be removed.
Arguments:
iq -- The command completion request.'

def _handle_command_complete(self, iq):

    node = iq['command']['node']
    sessionid = iq['command']['sessionid']
    session = self.sessions.get(sessionid)
    if session:
        handler = session['next']
        interfaces = session['interfaces']
        results = []
        for stanza in iq['command']['substanzas']:
            if (stanza.plugin_attrib in interfaces):
                results.append(stanza)
        if (len(results) == 1):
            results = results[0]
        if handler:
            handler(results, session)
        del self.sessions[sessionid]
        payload = session['payload']
        if (payload is None):
            payload = []
        if (not isinstance(payload, list)):
            payload = [payload]
        for item in payload:
            register_stanza_plugin(Command, item.__class__, iterable=True)
        iq.reply()
        iq['command']['node'] = node
        iq['command']['sessionid'] = sessionid
        iq['command']['actions'] = []
        iq['command']['status'] = 'completed'
        iq['command']['notes'] = session['notes']
        for item in payload:
            iq['command'].append(item)
        iq.send()
    else:
        raise XMPPError('item-not-found')
