(self)
Completes the websocket by calling the `closed`
        method either using the received closing code
        and reason, or when none was received, using
        the special `1006` code.

        Finally close the underlying connection for
        good and cleanup resources by unsetting
        the `environ` and `stream` attributes.
Completes the websocket by calling the `closed`
        method either using the received closing code
        and reason, or when none was received, using
        the special `1006` code.
Completes the websocket by calling the closed method either using the received closing code and reason or when none was received using the special 1006 code .
def terminate(self):
        """
        Completes the websocket by calling the `closed`
        method either using the received closing code
        and reason, or when none was received, using
        the special `1006` code.

        Finally close the underlying connection for
        good and cleanup resources by unsetting
        the `environ` and `stream` attributes.
        """
        s = self.stream

        self.client_terminated = self.server_terminated = True

        try:
            if not s.closing:
                self.closed(1006, "Going away")
            else:
                self.closed(s.closing.code, s.closing.reason)
        finally:
            self.close_connection()

            # Cleaning up resources
            s._cleanup()
            self.stream = None
            self.environ = None
def terminate ( self ) : s = self . stream self . client_terminated = self . server_terminated = True try : if not s . closing : self . closed ( 1006 , "Going away" ) else : self . closed ( s . closing . code , s . closing . reason ) finally : self . close_connection ( ) # Cleaning up resources s . _cleanup ( ) self . stream = None self . environ = None