title: Error closing PyQT app, after app.exec() returns
body: <p>Every time a simple PyQT GUI is quit from a QT Button, I see an error: <code>Must construct a QGuiApplication first.</code> The error comes after running the application for any amount of time, but only if a button is clicked which triggers <code>Qt.quit()</code>. If the app is stopped by closing the window, there is no error. So far, I've only tested on Ubuntu Artful, with PyQT packages from Ubuntu.</p>
  <p>The simplest app to demonstrate this is:</p>
  <h2>test.py</h2>
  <pre><code>#!/usr/bin/env python3
  
  import PyQt5.QtCore as QtCore
  import PyQt5.QtGui as QtGui
  import PyQt5.QtQml as QtQml
  
  
  
  def main():
      ''' setup and run the application '''
  
      # Create the application instance.
      app = QtGui.QGuiApplication([])
  
      # Create a QML engine.
      engine = QtQml.QQmlApplicationEngine(parent=app)
  
      engine.load(QtCore.QUrl('test.qml'))
  
      app.exec()
  
      print('a')   # &lt;--- This is printed before the QT error message
      return
  
  if __name__ == '__main__':
      main()
  
      print('b')
  </code></pre>
  <h2>test.qml</h2>
  <pre><code>import QtQuick 2
  import QtQuick.Controls 1.4
  
  
  ApplicationWindow {
      id: main_window
      visible: true
  
      Button {
          text: &quot;Quit&quot;
          onClicked: Qt.quit()
      }
  }
  </code></pre>
  <h2>output</h2>
  <pre><code>a
  Must construct a QGuiApplication first.
  b
  </code></pre>
  <p>The error comes after <code>app.exec()</code> finishes, but before <code>main()</code> returns.</p>
  <p>Is there something else that needs to be done to shutdown PyQT cleanly?</p>