After doing a ton of research I found this to be the best script to use. The "~" before the key does the pass-through of the key so you can get rid of the whole last part of your script.
~z::
duration := 0
If GetKeyState("z","p")
{
start := A_TickCount
While GetKeyState("z")
Sleep, 1
duration := A_TickCount - start
if (duration > 3000)
WinClose, ahk_exe {{{StartupEXE}}}
}
Return