Is 'try / finally' the best way for me to handle (and close) this long-running IMAP4 connection?
Move the working logic into its own function

def process_mailbox(mailbox):
    user = getpass.getuser() + '@mymailbox.com'
    try:
        mailbox.login(user, getpass.getpass())
    except imaplib.IMAP4.error:
        raise RuntimeError('Credential error.')
    mailbox.select('my_mailbox')
    #whatever else

def main():
    mailbox = imaplib.IMAP4_SSL('mymailbox.com', 993)
    try:
        process_mailbox(mailbox)
    finally:
        try:
            mailbox.close()    # which also expunges the mailbox
        except:
            pass
        mailbox.logout()