Some windows have a space in them like "Status Window", so place a quotes around them for the /window command.
; Keep the current window active, and place quotes around them.
var %active_window = $qt($active)
Not related, but I am curious about this section:
The ".echo -q" prevents the echo command from showing. Is that intended?
You might also be interested in the -n switch for the /query command to minimize the window.
; Open a query window for the user
query $nick
.echo -q $nick $timestamp $+ :: $nick has entered IRC.