<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def close(self):
 """ Close connection to an MS SQL Server. This function tries to close the connection and free all memory used. It can be called more than once in a row. No exception is raised in this case. """

        if self._conn:
            if self._pooling:
                _connection_pool.add(self._key, (self._conn, self._main_cursor._session))
            else:
                self._conn.close()
            self._active_cursor = None
            self._main_cursor = None
            self._conn = None
        self._closed = True