graceful shutdown

Wait for termination until `postQueue` is empty up to 30 seconds.

This patch is not perfect because it doesn't care `postDelay`, but good enough for first step.