diff --git a/lib/_debugger.js b/lib/_debugger.js index 10096b5eaa27..e4fa91672c3b 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -1540,9 +1540,8 @@ Interface.prototype.repl = function() { // Don't display any default messages var listeners = this.repl.rli.listeners('SIGINT').slice(0); this.repl.rli.removeAllListeners('SIGINT'); - - // Exit debug repl on Ctrl + C - this.repl.rli.once('SIGINT', function() { + + function exitDebugRepl(){ // Restore all listeners process.nextTick(function() { listeners.forEach(function(listener) { @@ -1552,7 +1551,16 @@ Interface.prototype.repl = function() { // Exit debug repl self.exitRepl(); - }); + + self.repl.rli.removeListener('SIGINT', exitDebugRepl); + self.repl.removeListener('exit', exitDebugRepl); + } + + // Exit debug repl on Ctrl + C + this.repl.rli.on('SIGINT', exitDebugRepl); + + // Exit debug repl on '.exit' + this.repl.on('exit', exitDebugRepl); // Set new this.repl.eval = this.debugEval.bind(this);