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

        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)
dataset/ETHPy150Open OfflineIMAP/imapfw/imapfw/imap/imaplib3/imaplib2.py/IMAP4.logout/original