'This decorator remembers a function as callback that should be
executed when the context tears down.  This is most useful to bind
resource handling to the script execution.  For instance, file objects
opened by the :class:`File` type will register their close callbacks
here.
:param f: the function to execute on teardown.'

def call_on_close(self, f):

    self._close_callbacks.append(f)
    return f
