if the IRCThread child defines stop_hook function, call it during clean shutdown.