def finalize(self):
if self._context is not None:<EOL><INDENT>if self._socket is not None:<EOL><INDENT>self._close_socket(confused=False)<EOL><DEDENT>self._context.term()<EOL>self._context = None<EOL>self._poll = None<EOL><DEDENT>
Closes socket and terminates context

        NO-OP if already closed.