Modal Close Error

Can someone help me ?
I want to close the a modal when a user on phone or browser clicks back button.
I used

  @HostListener('window:popstate', ['$event'])
  dismiss() {
      'dismissed': true

But its closed the modal and then went back a page.
I just want to close the modal and stay on the same page on back button click event