Prevent the metadata cache writer from being killed before it finished ...

...when calibre is shut down. This ensures that the cache is not truncated. Writing the cache for big libraries on a device can take many seconds. Example: on one mac writing a 6,000 book cache took 12 seconds.