How to prevent going back when back button is pressed while modal is open?

I’m using a IonModal on my page. When the modal is open and the user clicks back (on browser back button). It goes back to the previous page (instead of closing the modal / or doing nothing).

How can I prevent Ionic from doing this behavior?

I want either

  1. Close the modal (with back)
  2. Do nothing