title: scrapy: Call a function when a spider quits
body: <p>Is there a way to trigger a method in a Spider class just before it terminates?  </p>
  
  <p>I can terminate the spider myself, like this:</p>
  
  <pre><code>class MySpider(CrawlSpider):
      #Config stuff goes here...
  
      def quit(self):
          #Do some stuff...
          raise CloseSpider('MySpider is quitting now.')
  
      def my_parser(self, response):
          if termination_condition:
              self.quit()
  
          #Parsing stuff goes here...
  </code></pre>
  
  <p>But I can't find any information on how to determine when the spider is about to quit naturally.</p>