Use shutdown messages instead of interrupts

Use shutdown messages to stop the database and message handlers instead
of interrupting the threads.  This will allow an orderly shutdown.