Ensure that kernel is properly shutdown

When running ``runipy`` programmatically (e.g. #5) the kernel needs to be properly shutdown, otherwise a 'too many open files' error occurs.