server: Wait on terminal process for cleanup

The bash shell for the termianl is an exec.Cmd that is Start()ed
in the github.com/creack/pty package. We do a lot of cleanup
when that shell exits, but we never Wait() on it (and neither
does the pty package), so the bash process gets left behind
as a zombie.

Fixes boldsoftware/sketch#181
diff --git a/loop/server/loophttp.go b/loop/server/loophttp.go
index 8a65b4c..c72fe50 100644
--- a/loop/server/loophttp.go
+++ b/loop/server/loophttp.go
@@ -23,7 +23,6 @@
 	"strconv"
 	"strings"
 	"sync"
-	"syscall"
 	"time"
 
 	"github.com/creack/pty"
@@ -836,7 +835,9 @@
 	go s.readFromPtyAndBroadcast(sessionID, session)
 
 	return session, nil
-} // handleTerminalEvents handles SSE connections for terminal output
+}
+
+// handleTerminalEvents handles SSE connections for terminal output
 func (s *Server) handleTerminalEvents(w http.ResponseWriter, r *http.Request, sessionID string) {
 	// Check if the session exists, if not, create it
 	s.ptyMutex.Lock()
@@ -965,10 +966,9 @@
 
 		// Ensure process is terminated
 		if session.cmd.Process != nil {
-			session.cmd.Process.Signal(syscall.SIGTERM)
-			time.Sleep(100 * time.Millisecond)
 			session.cmd.Process.Kill()
 		}
+		session.cmd.Wait()
 
 		// Close all client channels
 		session.eventsClientsMutex.Lock()