title: get reference to current InteractiveShell instance in IPython (trying to hook %exit)
body: <p>I'd like to create a hook in IPython that runs when i do Cntl-D, %Exit, %Quit, or %exit and %quit and confirm.</p>
  
  <p>The motivation is that i want to have a thread that runs in IPython indefinitely in the background until i press Cntl-D to exit, and then i want to tell that thread to quit. I figure that i will use the hook to send a signal to my background thread.</p>
  
  <p>I figure one way to do this would be to wrap IPython::iplib::InteractiveShell::exit. Is this possible? Is there a better way to do what i am trying to do? thanks</p>