[Python-ideas] "atexit" equivalent for functions in contextlib