from qgis.core import QgsApplication QgsApplication.exitQgis()