<div dir="ltr">You could place your code in your plugin's unload() method.  But I'm not sure this would work, because some things might not be available at that time (e.g. layers, etc.).<div><br></div><div>See this page for a simple example</div>
<div><a href="http://www.qgis.org/en/docs/pyqgis_developer_cookbook/plugins.html">http://www.qgis.org/en/docs/pyqgis_developer_cookbook/plugins.html</a><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Feb 4, 2014 at 7:41 AM, McDonaldR <span dir="ltr"><<a href="mailto:McDonaldR@angus.gov.uk" target="_blank">McDonaldR@angus.gov.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">









<div lang="EN-GB" link="blue" vlink="purple">
<div>
<div><span style="FONT-SIZE:10pt;FONT-FAMILY:Arial"><font size="1">
</font></span></div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif"">Hi List<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif"">Is it possible for QGIS to run a (python) script on shutdown?  There is a feature on the QGIS issues list about startup scripts (<a href="http://hub.qgis.org/issues/6297" target="_blank">http://hub.qgis.org/issues/6297</a>)
 – can shutdown scripts be used in the same way?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif"">Say, for example, I have a project in which I am editing a dataset in a spatialite database. At the end of the edit session I save my work and shutdown QGIS. Before
 shutdown actually happens a python script/batch file runs which zips the spatialite database and copies it to a remote server location ready for processing by some other software.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif"">Thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif"">Ross<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#4f6228">Ross McDonald
</span></b><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#4f6228">|<b>
</b>GIS Data Coordinator | Resources Department, IT Division | Angus Council, Angus House, Orchardbank Business Park, Forfar, DD8 1AT<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:13.0pt;font-family:"Century Gothic","sans-serif";color:#4f6228">T:
<b>01307 476419</b> | F: 01307 476401 | E: <a href="mailto:mcdonaldr@angus.gov.uk" target="_blank">
<span style="color:#4f6228">mcdonaldr@angus.gov.uk</span></a> | W: <b><a href="http://www.angus.gov.uk/maps/map_home.cfm" target="_blank"><span style="color:#4f6228">Angus Maps</span></a></b><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div>
<font face="Arial" size="1">
</font> </div>
<div>
<p class="MsoNormal" style="MARGIN:0cm 0cm 0pt"><span style="FONT-SIZE:7.5pt;FONT-FAMILY:'Arial','sans-serif'"><font>This message is strictly confidential. If you have received this in error, please inform the sender and remove it from your system. If received in error you may not copy, print, forward or use it or any attachment in any way. This message is not capable of creating a legal contract or a binding representation and does not represent the views of Angus Council. Emails may be monitored for security and network management reasons.<span>  </span>Messages containing inappropriate content may be intercepted. Angus Council does not accept any liability for any harm that may be caused to the recipient system or data on it by this message or any attachment. </font></span></p>

</div>
</div></div>
<br>_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br></blockquote></div><br></div>