Fix handling of exitcode, name of "payload" key, add stub for shutdown.

I came across these errors while trying to create [octave_kernel](https://github.com/blink1073/octave_kernel).  Notice there is a TODO in there about shutting down gracefully.  I could not figure out how to do so.