WL-3014 Prevent shutdown deadlock.

When shutting down, we would change the status and interrupt the thread but before the other thread could process the interrupt we would also mark the maintenance thread to stop and interrupt it again. Then when the interrupt was processed we would jump out of sleep, see we were asked to change status, update the DB and then go back to sleep for the remainder of the sleep period.

The fix means we re-throw the error when we-re in shutdown which breaks us out of the fixed sleep loop.