[mihai's helpful answer](
[To see links please register here]
) works well if a _single_ Chrome window (typically containing multiple _tabs_) is open.
However, **more work is needed if you want to close _all_ open Chrome windows**:
; Get all hWnds (window IDs) created by chrome.exe processes.
WinGet hWnds, List, ahk_exe chrome.exe
; Loop over all hWnds and close them.
Loop, %hWnds%
{
hWnd := % hWnds%A_Index% ; get next hWnd
WinClose, ahk_id %hWnd%
}
Also note that the [`WinClose` documentation](
[To see links please register here]
) calls using `WinClose`'s use of the `WM_CLOSE` message "somewhat forceful" and suggests the following `PostMessage` alternative, which mimics the user action of pressing <kbd>Alt-F4</kbd> or using the Window menu's `Close` item:
; Get all hWnds (window IDs) created by chrome.exe processes.
WinGet hWnds, List, ahk_exe chrome.exe
; Loop over all hWnds and close them.
Loop, %hWnds%
{
hWnd := % hWnds%A_Index% ; get next hWnd
PostMessage, 0x112, 0xF060,,, ahk_id %hWnd%
}