Fix double-thread deinit problem