Make large "rejester clear" commands work better.

With >100000 work units, it can take longer than a single global-lock
timeout to actually do the clear.  Run one batch of list-and-delete
jobs under one lock, then re-get the lock.  Make one common support
function for all of the "remove_*_work_units" functions.