import win32gui, win32con
def enum_cb(hwnd, results):
    title = win32gui.GetWindowText(hwnd)
    if "Digital Optimus" in title or "tk" == title.lower() or "tk" in title.lower():
        print(f"Sent WM_CLOSE to window: {title} (hwnd {hwnd})")
        win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0)
win32gui.EnumWindows(enum_cb, None)
