Make sure you are adding task_sleep() inside a task context.
Not everything happens inside a task; most callset entry points are not in a task. Every 16.66ms, the scheduler runs every task that is ready, and then runs the idle callset. From idle, you can't do task_sleep. This is where switch scanning and periodics (idle_every_100ms) happen. So from those places, or any functions that might be called from them, sleep is not allowed.
As far as that goes, it should be ok to sleep in end_ball(), because it gets called from the ball device code which calls event from a per-device task.
However, on the 6809 there is another issue - limited stack space. If you have a deep call stack, with many nested function calls, and you sleep, there may not be enough room to save the entire call stack. end_ball is a problem because it gets called from device_remove_live, which is called from a dev_trough_enter, and so on back up the chain. Generally you can only sleep inside the same function where the task was started. I suspect that's what is happening.
The duration feature is a way of stopping multiple tasks at the same time. It would be possible for every module to register an end_ball event and kill its own tasks, but I found that error-prone and forgetting to kill some tasks would lead to strangeness. Now, every task by default will be stopped at end ball, and to make a task that is immune to that requires writing additional code.
Brian