void Window::OnCloseWindow(wxCloseEvent& event) { wxMessageDialog *dial = new wxMessageDialog(NULL, wxT("Are you sure to quit?"), wxT("Question"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION); int ret = dial->ShowModal(); dial->Destroy(); if (ret == wxID_YES) { Destroy(); NetworkManager* network = NetworkManager::getInstance(); delete network; //throw -1; } else { //DO stuff like checking veto } }