code: def close(self, status=1000, reason=u''):
          
          try:
              if self.closed is False:
                  close_msg = bytearray()
                  close_msg.extend(struct.pack("!H", status))
                  if _check_unicode(reason):
                      close_msg.extend(reason.encode('utf-8'))
                  else:
                      close_msg.extend(reason)
  
                  self._send_message(False, CLOSE, close_msg)
          finally:
              self.closed = True
docs: Send Close frame to the client. The underlying socket is only closed
             when the client acknowledges the Close frame.
  
             status is the closing identifier.
             reason is the reason for the close.