logic to stop a command