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