Refactor Scheduler to stop task