[WIP] global: free the error message when exiting a thread

When we free the global state at thread termination, we must also free
the error message in order not to leak the string once per thread.

---

Turns out we don't actually set an error message in our threaded tests, so we can't see this doing anything in the tests. I'll have to add that once I'm front a system with a working valgrind.