<div dir="ltr">Hi all,<div><br></div><div>I wrote the PyQt script below and I am running it through QGIS3. When I run it for the first time after opening it in QGIS3, the application's window pops up smoothly. However, when I close the window and run the script, QGIS3 readily quits.  That may be something related to the event loop, but I'm unsure and don't know how to stop the QGIS3 shutdown for the subsequent runs.  Any hint on how to fix this issue will be very appreciated. </div><div><br></div><div>import sys<br>from PyQt5.QtCore import (QSize,<br>                          Qt)<br>from PyQt5.QtWidgets import (QApplication,<br>                              QWidget,<br>                              QPushButton,<br>                              QMainWindow)<br></div><div>class MainWindow(QMainWindow):<br>    def _init_(self):<br>        super()._init_()<br>        self.setWindowTitle("My App")<br>        button = QPushButton("Press Me!")<br><br>       <br>        self.setCentralWidget(button)<br>        self.setFixedSize(QSize(400,300))<br clear="all"><div>app = QApplication(sys.argv)<br>window = MainWindow()<br>window.show() <br>app.exec()<br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><font face="verdana, sans-serif">##########################################</font></div><font size="4" face="verdana, sans-serif"><b><font color="#20124d">Julierme G Pinheiro</font></b><br><b><font color="#660000">SDI Expert & Geoprocessing Specialist</font></b></font><div><font size="4" face="verdana, sans-serif"><font color="#351c75">Phone:</font> <font color="#444444">+55 61 99994-3569</font></font></div><div><font size="4" face="verdana, sans-serif"><font color="#351c75">Website:</font> <a href="https://www.udemy.com/course/qgis-server-para-iniciantes-instalacao-e-configuracao/" target="_blank">GIS</a></font></div></div></div></div></div>