Best-effort drain before shutdown

Allow to drain the queue and wait until it's empty before shutdown is actually performed. It's a best-effort - shutdown still can return failed notifications, but less likely than with plain shutdown.