def stop(self, remove_volumes: bool = True) -> None:
        """Stop services using docker-compose.

        Args:
            remove_volumes: Whether to remove volumes when stopping
        """
        if not self.is_running:
            logger.info("Services are not running, nothing to stop")
            return

        # Change to tests directory
        os.chdir(self.tests_dir)

        try:
            # Only stop the backend service by default, keeping other services cached
            if "backend" in self.managed_services or not self.managed_services:
                logger.info("Stopping backend service...")
                stop_cmd = [
                    *self.compose_cmd,
                    "-f",
                    self.compose_file,
                    "-p",
                    DEFAULT_PROJECT_NAME,
                    "stop",
                    "backend",
                ]
                subprocess.run(stop_cmd, check=True)

                # Remove the backend container
                rm_cmd = [
                    *self.compose_cmd,
                    "-f",
                    self.compose_file,
                    "-p",
                    DEFAULT_PROJECT_NAME,
                    "rm",
                    "-f",
                    "backend",
                ]
                subprocess.run(rm_cmd, check=True)
                logger.info("Backend service has been stopped")

            # If explicitly asked to remove volumes, then stop all services
            if remove_volumes:
                logger.info("Removing volumes requested, stopping all services completely")
                cmd = [
                    *self.compose_cmd,
                    "-f",
                    self.compose_file,
                    "-p",
                    DEFAULT_PROJECT_NAME,
                    "down",
                    "-v",
                ]
                subprocess.run(cmd, check=True)
                logger.info("All services have been stopped and volumes removed")
            else:
                logger.info("Cached services are kept running for future test runs")

        except subprocess.CalledProcessError as e:
            logger.error(f"Error stopping Docker Compose: {e}")
            raise
        finally:
            # Change back to original working directory
            os.chdir(self.cwd)
            # Mark services as not running for this instance
            self.is_running = False
Stop services using docker-compose.

        Args:
            remove_volumes: Whether to remove volumes when stopping
        
backend/tests/helpers/docker.py