'(typ, [data]) = logout()
Shutdown connection to server.
Returns server \'BYE\' response.
NB: You must call this to shut down threads before discarding an instance.'

def logout(self, **kw):

    self.state = LOGOUT
    if __debug__:
        self._log(1, 'state    =>    LOGOUT')
    try:
        try:
            (typ, dat) = self._simple_command('LOGOUT')
        except:
            (typ, dat) = ('NO', [('%s:    %s' % sys.exc_info()[:2])])
            if __debug__:
                self._log(1, dat)
        self._close_threads()
    finally:
        self._release_state_change()
    if __debug__:
        self._log(1, 'connection    closed')
    bye = self._get_untagged_response('BYE', leave=True)
    if bye:
        (typ, dat) = ('BYE', bye)
    return self._deliver_dat(typ, dat, kw)
