Prevent the metadata cache writer from being killed before it finished when calibre is shut down. This ensures that the cache is not truncated.
Revert "Prevent the metadata cache writer from being killed before it finished when calibre is shut down. This ensures that the cache is not truncated."

This reverts commit 492f2da250f95d79d5d859bdf997696d39a7a0f2.
Alternate implementation that doesn't require the thread. Instead write the cache whenever sync_booklists is called, meaning the cache always be "almost right". Also, use a tmp file and atomic rename to prevent truncating the file if calibre dies while it is being written.
Merge branch 'master' of https://github.com/cbhaley/calibre