'Shuts down the scheduler and terminates the thread.
Does not interrupt any currently running jobs.
:param wait: ``True`` to wait until all currently executing jobs have
finished (if ``shutdown_threadpool`` is also ``True``)
:param shutdown_threadpool: ``True`` to shut down the thread pool
:param close_jobstores: ``True`` to close all job stores after shutdown'

def shutdown(self, wait=True, shutdown_threadpool=True, close_jobstores=True):

    if (not self.running):
        return
    self._stopped = True
    self._wakeup.set()
    if shutdown_threadpool:
        self._threadpool.shutdown(wait)
    if self._thread:
        self._thread.join()
    if close_jobstores:
        for jobstore in itervalues(self._jobstores):
            jobstore.close()
