Rewrite CancellableTaskFunc by implementing custom pipe.Task.

This works without requiring changes to pipe library.
It's possible to replace isKilled bool and polling with a channel and
select, also without changes to pipe library.