add shutdown command and add prepareShutdown check to have running commands finish before shutting down