debugger: also exit when the repl emits 'exit'

Fixes #5631
Could you use `once()` instead of `on()` so that you don't need to worry about removing the listener?