it should be noted that no feature name is ever deleted from _future_ thuseven if feature is turned on by default in later python versionno existing code that uses that feature name will break program termination program terminates when no more statements exist to execute in the input programwhen an uncaught systemexit exception is raised (as generated by sys exit())or when the interpreter receives sigterm or sighup signal (on unixon exitthe interpreter decrements the reference count of all objects in all the currently known namespaces (and destroys each namespace as wellif the reference count of an object reaches zerothe object is destroyed and its _del_ (method is invoked it' important to note that in some cases the _del_ (method might not be invoked at program termination this can occur if circular references exist between objects (in which case objects may be allocated but accessible from no known namespacealthough python' garbage collector can reclaim unused circular references during executionit isn' normally invoked on program termination because there' no guarantee that _del_ (will be invoked at terminationit may be good idea to explicitly clean up certain objectssuch as open files and network connections to accomplish thisadd specialized cleanup methods (for exampleclose()to user-defined objects another possibility is to write termination function and register it with the atexit moduleas followsimport atexit connection open_connection("deaddot com"def cleanup()print "going away close_connection(connectionatexit register(cleanupthe garbage collector can also be invoked in this mannerimport atexitgc atexit register(gc collectone final peculiarity about program termination is that the _del_ method for some objects may try to access global data or methods defined in other modules because these objects may already have been destroyeda nameerror exception occurs in _del_ _and you may get an error such as the followingexception exceptions nameerror'cin <method bar _del_ of bar instance at ignored if this occursit means that _del_ has aborted prematurely it also implies that it may have failed in an attempt to perform an important operation (such as cleanly shutting down server connectionif this is concernit' probably good idea to perform an explicit shutdown step in your coderather than rely on the interpreter to destroy objects cleanly at program termination the peculiar nameerror exception can also be lib fl ff