Add g_imap_logout() helper function.

It encapsulates the process of writing the LOGOUT message and reading
the response from server.

Signed-off-by: Thiago Farina <tfarina@chromium.org>