'Called as soon as Session shutdown is initiated. Used to start
shutdown tasks that takes some time and that can run in parallel
to checkpointing, etc.
:returns a Deferred that will fire once all dependencies acknowledge they have shutdown.'

@inlineCallbacks
def early_shutdown(self):

    self._logger.info('tlm:    early_shutdown')
    self.cancel_all_pending_tasks()
    self.shutdownstarttime = timemod.time()
    if self.boosting_manager:
        (yield self.boosting_manager.shutdown())
    self.boosting_manager = None
    if self.torrent_checker:
        (yield self.torrent_checker.shutdown())
    self.torrent_checker = None
    if self.channel_manager:
        (yield self.channel_manager.shutdown())
    self.channel_manager = None
    if self.search_manager:
        (yield self.search_manager.shutdown())
    self.search_manager = None
    if self.rtorrent_handler:
        (yield self.rtorrent_handler.shutdown())
    self.rtorrent_handler = None
    if self.video_server:
        (yield self.video_server.shutdown_server())
    self.video_server = None
    if self.version_check_manager:
        self.version_check_manager.stop()
    self.version_check_manager = None
    if self.tracker_manager:
        (yield self.tracker_manager.shutdown())
    self.tracker_manager = None
    if self.dispersy:
        self._logger.info('lmc:    Shutting    down    Dispersy...')
        now = timemod.time()
        try:
            success = (yield self.dispersy.stop())
        except:
            print_exc()
            success = False
        diff = (timemod.time() - now)
        if success:
            self._logger.info('lmc:    Dispersy    successfully    shutdown    in    %.2f    seconds', diff)
        else:
            self._logger.info('lmc:    Dispersy    failed    to    shutdown    in    %.2f    seconds', diff)
    if (self.metadata_store is not None):
        (yield self.metadata_store.close())
    self.metadata_store = None
    if (self.tftp_handler is not None):
        (yield self.tftp_handler.shutdown())
    self.tftp_handler = None
    if (self.channelcast_db is not None):
        (yield self.channelcast_db.close())
    self.channelcast_db = None
    if (self.votecast_db is not None):
        (yield self.votecast_db.close())
    self.votecast_db = None
    if (self.mypref_db is not None):
        (yield self.mypref_db.close())
    self.mypref_db = None
    if (self.torrent_db is not None):
        (yield self.torrent_db.close())
    self.torrent_db = None
    if (self.peer_db is not None):
        (yield self.peer_db.close())
    self.peer_db = None
    if (self.mainline_dht is not None):
        from Tribler.Core.DecentralizedTracking import mainlineDHT
        (yield mainlineDHT.deinit(self.mainline_dht))
    self.mainline_dht = None
    if (self.torrent_store is not None):
        (yield self.torrent_store.close())
    self.torrent_store = None
    if (self.api_manager is not None):
        (yield self.api_manager.stop())
    self.api_manager = None
    if (self.watch_folder is not None):
        (yield self.watch_folder.stop())
    self.watch_folder = None
