Work around gcc-mingw incorrect support for thread_local
We currently use a small thread_local object to automatically close each thread's sqlite connection. This works nicely when building for linux or cross compiling to windows using llvm-mingw, but it doesn't work properly when using i686-w64-mingw32-gcc
During my tests it ends up deadlocking when joining the thread (https://code.videolan.org/videolan/medialibrary/-/blob/master/src/compat/Thread.h#L173) but it can also lead to other issues:
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83562
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80883
- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80816
And ultimately, use of thread_local is discouraged: https://github.com/msys2/MINGW-packages/issues/2519#issuecomment-304155278