フォームに method="dialog" を付けると、送信でダイアログが閉じ、押したボタンの value が returnValue に入ります。JavaScript で閉じる処理を書く必要がありません。
method="dialog"
returnValue
まだ操作していません。