def close_spider(self, spider):
        """Close a spider being scraped and release its resources"""
        slot = self.slot
        slot.closing = defer.Deferred()
        slot.closing.addCallback(self.itemproc.close_spider)
        self._check_if_closing(spider, slot)
        return slot.closing
Close a spider being scraped and release its resources
stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/scraper.py