On exit command, check if there are any unsent messages

This commit doesn't actually work, though it looks like it should.  I've stepped through the debugger, and it does get to the line with:

    if (yield ui.choice('quit without sending message?',
                        select='yes', cancel='no',
                        msg_position='left') == 'no'):

but the message never actually appears.  When I get to this line it goes off somewhere into some defer code and eventually the application quits without ever showing the 'quit without sending message?' prompt.

Any pointers as to how to get this to work appreciated - I've lost a few messages due to quitting when I have an unsent message.