Index: nspr/pr/src/misc/prinit.c
--- nspr/pr/src/misc/prinit.c.orig
+++ nspr/pr/src/misc/prinit.c
@@ -373,8 +373,6 @@ PR_Cleanup()
         _PR_CleanupDtoa();
         _PR_CleanupCallOnce();
         _PR_ShutdownLinker();
-        _PR_CleanupNet();
-        _PR_CleanupIO();
         /* Release the primordial thread's private data, etc. */
         _PR_CleanupThread(me);
 
@@ -385,6 +383,12 @@ PR_Cleanup()
         _PR_LogCleanup();
 
         /*
+         * accesses the current thread
+         */
+        _PR_CleanupNet();
+        _PR_CleanupIO();
+
+        /*
          * This part should look like the end of _PR_NativeRunThread
          * and _PR_UserRunThread.
          */
@@ -396,6 +400,7 @@ PR_Cleanup()
             PR_DELETE(me->stack);
             PR_DELETE(me);
         }
+        _PR_MD_SET_CURRENT_THREAD(NULL);
 
         /*
          * XXX: We are freeing the heap memory here so that Purify won't
