cat-deploy: wait until tomcat is stopped, fix exit code handling