Add demo using flag to stop tasks.