The smartest way to toggle multiple events, like the raw events (raw replies of whois) in your script, would be a group.
Surround your raw lines with such a group:

Code:
#whoiswindow off
raw 311:*:{ 
  ...
  ... all the other raw lines here, too ...
  ...
raw 318:*:{ aline -p @Whois $+(10,$str(_,47)) | haltdef }
#whoiswindow end

We thus created a group called "#whoiswindow", all lines of code inside that group will be processed if the group is "on", or ignored if the group is "off".
If you want to stop the whois-ing itself, add the triggering command in that group as well (it's most likely a on join event).
Now we need a switch to toggle the group, e.g. a menu definition:
Code:
menu channel {
  Show whois in separate window $+([,$group(#whoiswindow),])
  .$iif(($group(#whoiswindow) == on),$style(1)) on : .enable #whoiswindow
  .$iif(($group(#whoiswindow) == off),$style(1)) off : .disable #whoiswindow
}