I have found a similar question in the forum: https://forum.mendix.com/#/questions/11540474045325104
Maybe the solution that Sander says could fit for your case:
“Seeing your comment at Henri, the solution is very simply.
Add a button on the page with action ‘Do nothing’ and add the CSS styling ‘display: none’. Then change the page properties (where you can change the page title) and at the bottom you can select which action you want to connect to the close button (that is also triggered by ESC key).
This way, if you press Esc, thus clicking on the X close button, you trigger the activity ‘Do nothing’.