For now, I'm making a deliberately minimal set of events because @fperez wants to consider this API experimental for 2.x. `atexit` works for the obvious case, and we can work out other hooks for e.g. embedded IPython later on.