[Issue 10095] Race condition causing corruption of mutexes when closing the database