Fixed IOError in print sys.stderr when the parent process exits.