diff --git a/client/src/modules/page_handlers/gameHandler.js b/client/src/modules/page_handlers/gameHandler.js index d8d0af5..499112b 100644 --- a/client/src/modules/page_handlers/gameHandler.js +++ b/client/src/modules/page_handlers/gameHandler.js @@ -18,6 +18,9 @@ import { InProgress } from '../game_state/states/InProgress.js'; import { Ended } from '../game_state/states/Ended.js'; export const gameHandler = (socket, window, gameDOM) => { + window.onunload = () => { + socket.close(); + }; document.body.innerHTML = gameDOM + document.body.innerHTML; injectNavbar(); const connectionHandler = () => {