diff -ru ../Ice-3.4.2.orig/py/modules/IcePy/Init.cpp ./py/modules/IcePy/Init.cpp
--- ../Ice-3.4.2.orig/py/modules/IcePy/Init.cpp	2011-06-15 12:44:00.000000000 -0700
+++ ./py/modules/IcePy/Init.cpp	2013-08-31 10:43:39.000000000 -0700
@@ -29,6 +29,7 @@
 using namespace IcePy;
 
 extern "C" PyObject* Ice_registerTypes(PyObject*, PyObject*);
+extern "C" PyObject* IcePy_cleanup(PyObject*);
 
 static PyMethodDef methods[] =
 {
@@ -70,6 +71,8 @@
         PyDoc_STR(STRCAST("internal function")) },
     { STRCAST("loadSlice"), reinterpret_cast<PyCFunction>(IcePy_loadSlice), METH_VARARGS,
         PyDoc_STR(STRCAST("loadSlice(cmd) -> None")) },
+    { STRCAST("cleanup"), reinterpret_cast<PyCFunction>(IcePy_cleanup), METH_NOARGS,
+        PyDoc_STR(STRCAST("internal function")) },
     { 0, 0 } /* sentinel */
 };
 
@@ -150,3 +153,13 @@
         return;
     }
 }
+
+extern "C"
+PyObject*
+IcePy_cleanup(PyObject* /*self*/)
+{
+    cleanupLogger();
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
diff -ru ../Ice-3.4.2.orig/py/modules/IcePy/Logger.cpp ./py/modules/IcePy/Logger.cpp
--- ../Ice-3.4.2.orig/py/modules/IcePy/Logger.cpp	2011-06-15 12:44:00.000000000 -0700
+++ ./py/modules/IcePy/Logger.cpp	2013-08-31 10:33:03.000000000 -0700
@@ -400,6 +400,15 @@
     return true;
 }
 
+void
+IcePy::cleanupLogger()
+{
+    //
+    // Python is about to exit; we need to remove the wrapper around the process logger.
+    //
+    Ice::setProcessLogger(0);
+}
+
 PyObject*
 IcePy::createLogger(const Ice::LoggerPtr& logger)
 {
diff -ru ../Ice-3.4.2.orig/py/modules/IcePy/Logger.h ./py/modules/IcePy/Logger.h
--- ../Ice-3.4.2.orig/py/modules/IcePy/Logger.h	2011-06-15 12:44:00.000000000 -0700
+++ ./py/modules/IcePy/Logger.h	2013-08-31 10:32:30.000000000 -0700
@@ -41,6 +41,8 @@
 
 bool initLogger(PyObject*);
 
+void cleanupLogger();
+
 //
 // Create a Python object that delegates to a C++ implementation.
 //
diff -ru ../Ice-3.4.2.orig/py/python/Ice.py ./py/python/Ice.py
--- ../Ice-3.4.2.orig/py/python/Ice.py	2011-06-15 12:44:00.000000000 -0700
+++ ./py/python/Ice.py	2013-08-31 10:44:36.000000000 -0700
@@ -53,6 +53,12 @@
     sys.setdlopenflags(_dlopenflags)
 
 #
+# Give the extension an opportunity to clean up before a graceful exit.
+#
+import atexit
+atexit.register(IcePy.cleanup)
+
+#
 # Add some symbols to the Ice module.
 #
 ObjectPrx = IcePy.ObjectPrx
