<p>As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions?</p>

<pre><code>import atexit

def helloworld():
    print("Hello World!")

atexit.register(helloworld)

raise Exception("Good bye cruel world!")
</code></pre>

<p>outputs</p>

<pre><code>Traceback (most recent call last):
  File "test.py", line 8, in &lt;module&gt;
    raise Exception("Good bye cruel world!")
Exception: Good bye cruel world!
Hello World!
</code></pre>

If you call
```
```
import os
os._exit(0)
```
```
the exit handlers will not be called, yours or those registered by other modules in the application.