Update Imap.php

You need to send "CLOSE" before "LOGOUT" to remove delete-flagged messages from active message box - or: provide (at least) a function to do so manually
Fix for issue #1