Stop a program without breaking the script?

Hello there!

I am creating a script, that among other functions will run iperf (network stress tool) either on server or client mode.

The thing is that it will run forever if the user does not stop it or break it. CTRL-C will break it. I need a method, however, that will break iperf and then return to the script line right after where it was called:

echo -n "  Choose mode: [C]lient or erver: "
read MODE
while [ "$MODE" != "C" -a "$MODE" != "S" ]
do
if [ "$MODE" == "S"  ]
then
	iperf -s -i 1
	exit
else
	if [ "$MODE" == "C"  ]
	then
		echo ""
		echo "  Server IP?:"
		read IP
		iperf -c $IP -t 300 -i 1
		exit
	else
	fi
fi
done

Any ideas?

The line right after it is 'exit' anyway. What's the difference?

You can run iperf in the background, and have your script kill it whenever you please.

Nevermind... I thought it would break everything, but it falls right back where I want to... tks!