The problem is you are trying to handle it from the beforeSave() method. You should write it in the getHeaderActions().
In the getHeaderActions() make the custom save action, then within use the - >requiresConfirmation() function, and - > modalSubHeading('Are you sure you want to save these changes?')
I hope it helps.