<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _cleanup(self):
 """Remove the connection from the stack, closing out the cursor"""

        if self._cursor:
            LOGGER.debug('Closing the cursor on %s', self.pid)
            self._cursor.close()
            self._cursor = None

        if self._conn:
            LOGGER.debug('Freeing %s in the pool', self.pid)
            try:
                pool.PoolManager.instance().free(self.pid, self._conn)
            except pool.ConnectionNotFoundError:
                pass
            self._conn = None