Do I understand correctly: The sound is not triggered by the code itself, but by moving the cursor out of the modal dialog? (Which operating system produces this behaviour?) If so, what about leaving the pointer inside the dialog, because you cannot click to anything outside at all?
As fas as I know under Windows the warning sounds appear only, if you try to click on external objects outside the modal dialog, and this is the wanted behavior to remember the user, why the computer does not react to these clicks.
You can open the waitbar without the modal-flag and use another tool to keep the window on top - searching for these terms in the FEX will be helpful.