Fix an error when closing the game from the inventory menu.