rationalise timer maintenance
- introduce a couple of helper functions and use them wherever we can
- pay attention to the result of timer cancellation, to prevent
  duplicate timer creation
- stop all timers when a queue terminates. More out of politeness than
  necessity.
...and do the same thing here.
Merge bug25393