Add proper shutdown behavior.