cleanup shared and thread-local variables