core: Make cmdline.Command.Main return an exit code instead of exiting.

Change-Id: Ife34378019ee25cc4d6809f1b3923a8e4f234572
MultiPart: 1/3Change-Id: Idf9bab4a66f7da4b06a12943c746b05082d69f60
diff --git a/tools/debug/main.go b/tools/debug/main.go
index 7368a9c..cab2605 100644
--- a/tools/debug/main.go
+++ b/tools/debug/main.go
@@ -4,6 +4,8 @@
 package main
 
 import (
+	"os"
+
 	"v.io/core/veyron2"
 	"v.io/core/veyron2/rt"
 
@@ -18,6 +20,8 @@
 	if err != nil {
 		panic(err)
 	}
-	defer runtime.Cleanup()
-	root().Main()
+
+	exitCode := root().Main()
+	runtime.Cleanup()
+	os.Exit(exitCode)
 }