mgmt test: clean up leaking processes

This change should resolve bug #622
https://github.com/vanadium/issues/issues/622

Change-Id: I5fc252a0b032dc45cdbe3313f9164395229bfa3f
diff --git a/v23/syncbase/mgmt_v23_test.go b/v23/syncbase/mgmt_v23_test.go
index 0384c7e..66d4acf 100644
--- a/v23/syncbase/mgmt_v23_test.go
+++ b/v23/syncbase/mgmt_v23_test.go
@@ -285,6 +285,28 @@
 	appBlessing := mfrBlessing + "/a/" + pubBlessing + "," + ownerBlessing + "/a/" + pubBlessing
 	inv = debugBin.Start("stats", "read", instanceName+"/stats/security/principal/*/blessingstore")
 	inv.ExpectSetEventuallyRE(".*Default Blessings[ ]+"+userBlessing+"$", "[.][.][.][ ]+"+userBlessing+","+appBlessing)
+
+	// Kill and delete the instance.
+	deviceBin.Run("kill", instanceName)
+	deviceBin.Run("delete", instanceName)
+
+	// Shut down the device manager.
+	deviceScript.Run("stop")
+
+	// Wait for the mounttable entry to go away.
+	resolveGone := func(name string) string {
+		resolver := func() (interface{}, error) {
+			inv := namespaceBin.Start("resolve", name)
+			defer inv.Wait(nil, os.Stderr)
+			if r := strings.TrimRight(inv.Output(), "\n"); len(r) == 0 {
+				return r, nil
+			}
+			return nil, nil
+		}
+		return i.WaitFor(resolver, 100*time.Millisecond, time.Minute).(string)
+	}
+	resolveGone(mtName)
+	deviceScript.Run("uninstall")
 }
 
 func buildAndCopyBinaries(i *v23tests.T, destinationDir string, packages ...string) {