diff --git a/exec/irc.js b/exec/irc.js
index 12f79a2d95b2b418a32f9f4075670bfaf03fd315..b3df31f47124b540e33c81f324c8a4073abedffa 100644
--- a/exec/irc.js
+++ b/exec/irc.js
@@ -7,13 +7,7 @@
 
 // disable auto-termination.
 var old_auto_terminate=js.auto_terminate;
-
-function restore_auto_terminate()
-{
-	js.auto_terminate=old_auto_terminate;
-}
-
-js.on_exit("restore_auto_terminate");
+js.on_exit("js.auto_terminate=old_auto_terminate");
 js.auto_terminate=false;
 
 const REVISION = "$Revision$".split(' ')[1];