The requestClose() method of the HTMLDialogElement interface requests to close the . An optional string may be passed as an argument, updating the returnValue of the dialog.
requestClose()
MDN Reference