Solution
By default, the ArkUI dialog box is not a page-level dialog box. Dialog boxes do not close automatically when you switch pages unless you manually call the close method. To enable a dialog box to be dismissed during page redirection, consider using the navigation page displayed in dialog mode (applicable to scenarios where the navigation stack relationship needs to be maintained) or page-level dialog box (applicable to scenarios where full-screen modal coverage is required).
Reference