def close(self, status=<NUM_LIT:1000>, reason=u'<STR_LIT>'):
try:<EOL><INDENT>if self.closed is False:<EOL><INDENT>close_msg = bytearray()<EOL>close_msg.extend(struct.pack("<STR_LIT>", status))<EOL>if _check_unicode(reason):<EOL><INDENT>close_msg.extend(reason.encode('<STR_LIT:utf-8>'))<EOL><DEDENT>else:<EOL><INDENT>close_msg.extend(reason)<EOL><DEDENT>self._sendMessage(False, CLOSE, close_msg)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>self.closed = True<EOL><DEDENT>
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.