Seeing where these globals are declares (cf3globals.c) I would guess the best place would be GenericAgentDeInitialise() or however it's called. 

But still I'm not sure, you'll have to verify this won't break any existing threads. It's not that easy, that's why some things have not been touched by anybody yet. :-p