class MyDaemonContext(daemon.DaemonContext):

    def close(self):
        if not self.is_open:
            return
prevent_the_apocalypse()
super(MyDaemonContext, self).close()
with MyDaemonContext():
    while True:
        pass
Proper way to clean up a Python service -- atexit, signal, try/finally