add: if (outboxFolder) outboxFolder->close(TRUE); if (sentFolder) sentFolder->close(TRUE); if (trashFolder) trashFolder->close(TRUE);
context: static void cleanup(void){  shuttingDown = TRUE;  if (inboxFolder) inboxFolder->close(TRUE);  if (msgSender) delete msgSender;  if (filterMgr) delete filterMgr;  if (acctMgr) delete acctMgr;  if (folderMgr) delete folderMgr;  if (kbp) delete kbp;  qInstallMsgHandler(oldMsgHandler);  app->getConfig()->sync();}