I was running a process that would login to gmail parse messages, logout and repeat. Unfortunately the number of open TCP sockets for this process kept increasing with time and at some point (hours later) my process crashed with a Too many open connections error.
Added a disconnect method which basically calls @imap.disconnect. Let me know if you need me to tweak it. Thanks for the library.
Added a disconnect method to teardown connection