code: async def do_teardown_websocket(
              self,
              exc: Optional[BaseException],
              websocket_context: Optional[WebsocketContext]=None,
      ) -> None:
          
          websocket_ = (websocket_context or _websocket_ctx_stack.top).websocket
          functions = self.teardown_websocket_funcs[None]
          blueprint = websocket_.blueprint
          if blueprint is not None:
              functions = chain(functions, self.teardown_websocket_funcs[blueprint])  # type: ignore
  
          for function in functions:
              await function(exc=exc)
          await websocket_tearing_down.send(self, exc=exc)
docs: Teardown the websocket, calling the teardown functions.
  
          Arguments:
              exc: Any exception not handled that has caused the websocket
                  to teardown.
              websocket_context: The websocket context, optional as Flask
                  omits this argument.