kernel/kernel.py: Implement clean shutdown handling in Tornado