How to cancel in progress tasks from the database