Sqlite uses a few temporary files to support multiprocess usage of the same db https://sqlite.org/tempfiles.html
file is created when the first connection to the database is opened and is normally removed when the last connection to the database closes. However, if the last connection does not shutdown cleanly, the WAL file will remain in the filesystem and will be automatically cleaned up the next time the database is opened.
We were getting intermittent errors while trying to clean up the instance directory due to these files being removed *during* the temp dir cleanup process.
This was because the _check_for_zombies thread opens the runs database to read the run state and we were not shutting the thread down and instead letting it close at process exit via its daemonization.
This diff stops the thread in the join call to resolve the issue.