2通りの方法があります。
1つ目:game.input_binding に ESC キーを登録してスクリプトでチェックする方法
game.input_binding を開き、ESCキーをAction として登録します。

スクリプトを書く
登録した Action を on_input でチェックします。
function on_input(self, action_id, action)
if action_id == hash("escape") and action.pressed then
sys.exit(0)
end
end
二つ目:Preferences からESCでゲームを終了する様の設定する
[File] -> [Preferences…] -> [General] のEscape Quits Game にチェックを入れる

こちらの方が楽ですが、閉じて欲しくないタイミングでも閉じることが出来るので、時と場合で使い分けてあげると良いですね。