stop task when closing and optionally control an external widget