At the time I asked this question there was no escape option in confirm
component but it was implemented on PrimeFaces 6.2 after this feature request.
So now we can just do it this way:
Alternatively, it's possible to use confirmDialog
component as already suggested in other answers.