Reinitializes the terminal: enables raw mode, enters the alternate screen,
enables mouse capture, clears the screen, and creates a new Terminal instance.
This function updates the provided terminal reference.
Runs the given example (or binary) target. It leaves TUI mode, spawns a cargo process,
installs a Ctrl+C handler to kill the process, waits for it to finish, updates history,
flushes stray input, and then reinitializes the terminal.