Call thread_data_free before g_thread_exit