put showMainCloseDlg to trap function as well