Updated shutdown command to avoid race conditions on System.exit