Add routine to gracefully shutdown the kernel