Added callback for checking whether tasks should be sent to scheduler.

This is used to prevent new tasks being sent when battery is low.

Also made task_routine killable further.