Here's a "not so nice" method (since it will not wait for you to save your data or confirm closing each script) that you can try that might also close compiled scripts (**not extensively tested and may contain errors - USE AT YOUR OWN RISK)
Code:
DetectHiddenWindows, On
ahk := DllCall("FindWindowEx", "Int", 0, "UInt", ahk, "Str", "AutoHotkey", "Str", A_ScriptFullPath . " - " . "AutoHotkey v" . A_AhkVersion)
ahkme = %ahk%
count := 0
notclosed := 0
Loop
{
ahk := DllCall("FindWindowEx", "Int", 0, "UInt", ahk, "Str", "AutoHotkey", "Int", 0)
If (ahk) {
IfInString, ahkf, `,%ahk%`,
{
MsgBox, Endless loop detected while trying to close %ahk%
break
}
If (ahk = ahkme) {
If (lastahk = ahkme)
break
Else
continue
}
If (ahk) AND !(ahk = ahkme){
DllCall("EndTask", UInt, ahk, uint, 0, uint, 1)
Sleep, 250
}
If (DllCall("IsWindow", "UInt", ahk)) {
WinClose, ahk_id %ahk%
Sleep, 250
}
If (DllCall("IsWindow", "UInt", ahk)) {
WinKill, ahk_id %ahk%
Sleep, 250
}
If (DllCall("IsWindow", "UInt", ahk)) {
PostMessage, 0x112, 0xF060,,, ahk_id %ahk% ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE
Sleep, 250
}
If !(DllCall("IsWindow", "UInt", ahk)) {
count++
} Else {
notclosed++
}
ahkf .= "," . ahk . ","
lastahk = %ahk%
}
else If !(DllCall("FindWindowEx", "Int", 0, "UInt", ahkme, "Str", "AutoHotkey", "Int", 0))
break
}
MsgBox, %count% AutoHotkey processes were closed.`n%notclosed% AutoHotkey processes were detected but could not be closed using this method
Edit: added DectectHiddenWindows