async def _hang_up_call(self):
        """Hang up the Twilio call using Twilio's REST API."""
        try:
            import aiohttp

            account_sid = self._account_sid
            auth_token = self._auth_token
            call_sid = self._call_sid

            if not call_sid or not account_sid or not auth_token:
                missing = []
                if not call_sid:
                    missing.append("call_sid")
                if not account_sid:
                    missing.append("account_sid")
                if not auth_token:
                    missing.append("auth_token")

                logger.warning(
                    f"Cannot hang up Twilio call: missing required parameters: {', '.join(missing)}"
                )
                return

            # Twilio API endpoint for updating calls
            endpoint = (
                f"https://api.twilio.com/2010-04-01/Accounts/{account_sid}/Calls/{call_sid}.json"
            )

            # Create basic auth from account_sid and auth_token
            auth = aiohttp.BasicAuth(account_sid, auth_token)

            # Parameters to set the call status to "completed" (hang up)
            params = {"Status": "completed"}

            # Make the POST request to update the call
            async with aiohttp.ClientSession() as session:
                async with session.post(endpoint, auth=auth, data=params) as response:
                    if response.status == 200:
                        logger.info(f"Successfully terminated Twilio call {call_sid}")
                    else:
                        # Get the error details for better debugging
                        error_text = await response.text()
                        logger.error(
                            f"Failed to terminate Twilio call {call_sid}: "
                            f"Status {response.status}, Response: {error_text}"
                        )

        except Exception as e:
            logger.exception(f"Failed to hang up Twilio call: {e}")
Hang up the Twilio call using Twilio's REST API.
src/pipecat/serializers/twilio.py