Cant close connection beetween peer on peerjs

i’m building a video chat app using peerjs with ionic angular. its working like i wanted except i cant end the call. here’s how i call other user

call(userId: string, partnerId: string) {
    const conn = this.peer.connect(partnerId);
    conn.on('open', () => {
      conn.on('data', (data) => {
        console.log(data);
      })
      conn.send(userId);
    })
    if (this.peer.destroyed) {
      this.createPeer(this.userId);
    }

    if (this.myEl.classList.contains('disableCall')) {
      console.log('Show');
      this.myEl.classList.add('showCall');
      this.partnerEl.classList.add('showCall');
      this.myEl.classList.remove('disableCall');
      this.partnerEl.classList.remove('disableCall');
    }
    this.hideCallLogin = false;
    const call = this.peer.call(partnerId, this.myStream);
    this.mediaConnection = call;
    call.on('stream', (stream) => {
      this.partnerEl.srcObject = stream;
      this.hideCall = true;
      this.hideCallLogin = false;
      if (call.peerConnection.connectionState == 'connecting') {
        this.swapVideo('my-video');
      }
    });
    call.on('close', () => {
      console.log('Di hentikan oleh penerima');
      this.mediaConnection.close();
      this.myEl.classList.remove('showCall');
      this.partnerEl.classList.remove('showCall');
      this.myEl.classList.add('disableCall');
      this.partnerEl.classList.add('disableCall');
      this.hideCall = false;
      this.hideCallLogin = false;
    })
  }

and here’s how i wait for an answer

wait() {
    this.peer.on('call', (call) => {
      this.mediaConnection = call;
      //change this to a modal for confirm a call
      var acceptsCall = confirm(partner + " is calling, do you want to accept it ?");
      if (acceptsCall) {
        call.answer(this.myStream); // Answer the call with an A/V stream.
        call.on('stream', (stream) => {
          if (this.myEl.classList.contains('disableCall')) {
            console.log('Show');
            this.partnerEl.classList.add('showCall');
            this.myEl.classList.add('showCall');
            this.partnerEl.classList.remove('disableCall');
            this.myEl.classList.remove('disableCall');
          }
          this.partnerEl.srcObject = stream;
          this.status = 'Connected';
          this.hideCallLogin = false;
          this.swapVideo('my-video');
        });
        call.on('close', () => {
          console.log('Di hentikan oleh penelpon');
          this.myEl.classList.remove('showCall');
          this.partnerEl.classList.remove('showCall');
          this.myEl.classList.add('disableCall');
          this.partnerEl.classList.add('disableCall');
          console.log(this.status);
          this.hideCall = false;
          this.hideCallLogin = false;
        })
      }
    });
    //getting partner id
    let partner = '';
    this.peer.on('connection', (conn) => {
      conn.on('open', () => {
        conn.on('data', (data) => {
          partner = data;
        })
      })
    })

  }

i use this code to terminate all connection

    this.mediaConnection.close();
    this.myEl.pause();

i found that to close connection i should use call.close() but now still it only affect the user that ended the call. on the other user, i listen to on(‘close’) but nothing’s happenning there, any ide?

What exactly do you mean by not being able to finish the search? Does the peer continue to receive audio or video after being destroyed?

I also found a section in the peerjs document. You can listen to the close event.

i updated my question