No, there’s no generally safe way to interrupt a task. But you can interrupt any waitable object (by closing it).