Not able to end the session in WebRTC using sessionId

Hello everyone, I am trying to use the SDK API and WebRtcSDK in a javascript in the test html page we are making for a usecase. I am on our first experience with GenesysCloud so I am probably doing something wrong. Our test page downloads the following javascript from the network, which is then executed by the browser:
https://sdk-cdn.mypurecloud.com/javascript/latest/purecloud-platform-client-v2.min.js 2
https://sdk-cdn.mypurecloud.com/webrtc-sdk/v8/genesys-cloud-webrtc-sdk.bundle.min.js 3

The initialisation and authentication of the "platformClient.ApiClient" works correctly and we are able to generate the softphonesession using but i am
not able to end the session using the forceTerminateSession() method.It is giving the error not able to find the session by sessionId I am passing the
sessionId that got from the startSoftphoneSession() method.

this is the error i am getting:

Error terminating call: Error: Failed to find session by sessionId
at E.Rr (utils.ts:40:17)
at e. (session-manager.ts:417:35)
at b (runtime.js:63:40)
at Generator._invoke (runtime.js:294:22)
at Generator.next (runtime.js:119:21)
at i (asyncToGenerator.js:5:20)
at s (asyncToGenerator.js:27:9)
at asyncToGenerator.js:34:7
at new Promise ()
at new t (export.js:16:24)
code:

<script src="https://sdk-cdn.mypurecloud.com/webrtc-sdk/v8/genesys-cloud-webrtc-sdk.bundle.min.js"></script>

<script>
    let conversationId;
    let sessionId;
    const clientId = 'xxxxxaab';
    const redirectUri = 'https://abcbc.com';
                    
  
  

  endCallButton.addEventListener('click', async () => {
    try {
       console.log(sessionId);

    const resp=await webRtcSDK.forceTerminateSession(sessionId);
    console.log(resp);
    console.log('Call terminated successfully.');
    } 
    catch (error) {
    console.error('Error terminating call:', error);
}

});

function initWebRtcSDK() {     
    webRtcSDK = new window.GenesysCloudWebrtcSdk.GenesysCloudWebrtcSdk({
    accessToken: ,
    environment: ''  
  });
  console.log('WebRTC SDK inited.');
  webRtcSDK.on('sdkError', (event) => {
    console.log("Event error -> " + event);
  });
  webRtcSDK.on('pendingSession', (event) => {
    if (event.conversationId === conversationId) {

    webRtcSDK.acceptPendingSession(event.sessionId)
        .then(() => {
            console.log('Pending session accepted for outbound call.');
        })
        .catch((error) => {
            console.error('Error accepting pending session:', error);
        });
}
  });
  webRtcSDK.on('sessionStarted', (event) => {
    console.log("Event sessionStarted -> " + event);
  });
  webRtcSDK.initialize().then(()=>{
    console.log("webrtc is intialized");
    initSoftphoneSessionAsync(webRtcSDK);

  })
}

async function initSoftphoneSessionAsync(webRtcSDK) {
  console.log('Call startSoftphoneSession method');      
  const sessionInfo = await webRtcSDK.startSoftphoneSession({ phoneNumber: 'xxxxxxxxxx' });
  console.log('call started');
  //const sessionObject=JSON.stringify(sessionInfo);
   console.log(sessionInfo);
   sessionId = sessionInfo['id'];
   console.log(sessionId);
  
  console.log('startSoftphoneSession invocation returned: ',JSON.stringify(sessionInfo)); 
}

</script>