working graceful shutdown (even on kill signals). #451