replace the ID with the task ID from Monitor > Tasks (not from the dynflow console)
For Katello 3.0 & Satellite 6.2:
foreman-rake foreman_tasks:cleanup FILTER='id=1cc6495d-f7ee-4011-9659-ea24ae9240f0' STATES=paused,stopped VERBOSE=true
For Later versions:
foreman-rake foreman_tasks:cleanup TASK_SEARCH='id=1cc6495d-f7ee-4011-9659-ea24ae9240f0' STATES=paused,stopped VERBOSE=true