Criei uma aplicação para alternar as abas do navegador, só que dá erro quando tenta fechar.
Como parar a execução quando clicar em fechar?
Tem como colocar um botão de parada?
import webbrowser
import PySimpleGUI as sg
import webbrowser
import pyautogui
import sys
# pyinstaller --onefile C:\Users\01518891\PycharmProjects\core_box_image\chrome.py --noconsole
# Janela inicial, Interface do Programa
def tela_inicial():
    # Tema
    sg.theme('Reddit')
    # Conjunto de blocos do layout
    layout = [
        # Cria os espaços para colocar os links
        [sg.Text("LINK 01"),
         sg.Input(key='link_01')],
        [sg.Text("LINK 02"),
         sg.Input(key='link_02')],
        [sg.Text("LINK 03"),
         sg.Input(key='link_03')],
        [sg.Text("LINK 04"),
         sg.Input(key='link_04')],
        [sg.Text("LINK 05"),
         sg.Input(key='link_05')],
        # Controles do aplicativo
        # Botão INICIAR
        [sg.Button("INICIAR"),
         # Spin para colocar a quantidade de tempo para execução
         sg.T('TEMPO DE EXECUÇÃO (Minutos)'),
         sg.Spin((1, 2, 3, 4, 5, 6, 7, 8, 9, 10), initial_value=1, key='intervalo')
         ]
    ]
    return sg.Window('EXIBIR LINKS EXPLORAÇÃO', layout=layout, finalize=True)
# Criar Janela
tela_inicial = tela_inicial()
def executar_chrome(link):
    if len(link) <= 0:
        pass
    else:
        webbrowser.open_new_tab(link)
# Criando a leitura de eventos
while True:
    window, event, values = sg.read_all_windows()
    # Quando a janela for fechada
    if window == tela_inicial and event == sg.WIN_CLOSED:
        break
    if window == tela_inicial and event == 'INICIAR':
        link_01 = str(window['link_01'].get())
        link_02 = str(window['link_02'].get())
        link_03 = str(window['link_03'].get())
        link_04 = str(window['link_04'].get())
        link_05 = str(window['link_05'].get())
        executar_chrome(link_01)
        executar_chrome(link_02)
        executar_chrome(link_03)
        executar_chrome(link_04)
        executar_chrome(link_05)
        for i in range(500):
            pyautogui.hotkey('ctrl', 'tab')
            window.read(timeout=10000 * int(window['intervalo'].get()))
window.close()Desde Já agradeço!
