Ensure shutdown sub command

It causes a resource leak.