'Pops the request context and unbinds it by doing that.  This will
also trigger the execution of functions registered by the
:meth:`~flask.Flask.teardown_request` decorator.
.. versionchanged:: 0.9
Added the `exc` argument.'

def pop(self, exc=_sentinel):

    app_ctx = self._implicit_app_ctx_stack.pop()
    try:
        clear_request = False
        if (not self._implicit_app_ctx_stack):
            self.preserved = False
            self._preserved_exc = None
            if (exc is _sentinel):
                exc = sys.exc_info()[1]
            self.app.do_teardown_request(exc)
            if hasattr(sys, 'exc_clear'):
                sys.exc_clear()
            request_close = getattr(self.request, 'close', None)
            if (request_close is not None):
                request_close()
            clear_request = True
    finally:
        rv = _request_ctx_stack.pop()
        if clear_request:
            rv.request.environ['werkzeug.request'] = None
        if (app_ctx is not None):
            app_ctx.pop(exc)
        assert (rv is self), ('Popped    wrong    request    context.        (%r    instead    of    %r)' % (rv, self))
