pyqt close window and continue process code example

Example: self.close() pyqt5 not working

class Ui_Dialog(QtWidgets.QMainWindow):
    def setupUi(self, Dialog):
    Dialog.setObjectName("Dialog")
    Dialog.resize(346, 182)
    self.pushButton = QtWidgets.QPushButton(Dialog)
    self.pushButton.setGeometry(QtCore.QRect(110, 80, 75, 23))
    self.pushButton.setObjectName("pushButton")

    self.pushButton.clicked.connect(self.exit)

    self.retranslateUi(Dialog)
    QtCore.QMetaObject.connectSlotsByName(Dialog)

    def exit(self):
        self.hide() #This also not working, I want either of these two to 
                    #work

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
        self.pushButton.setText(_translate("Dialog", "OK"))