locking: on shutdown, only release the master lock if it belongs to us