import sys from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton class MainWindow(QMainWindow): def __init__(self): super().__init__() button = QPushButton("Exit", self) button.clicked.connect(QApplication.exit) self.setGeometry(100, 100, 300, 200) self.show() app = QApplication(sys.argv) window = MainWindow() app.exec_()In this example, a simple application is created with a main window containing a push button. When the button is clicked, the `exit` method of QApplication is called which terminates the application. Package library: PySide2.QtWidgets.