Index: /issm/trunk-jpl/jenkins/jenkins.sh
===================================================================
--- /issm/trunk-jpl/jenkins/jenkins.sh	(revision 26762)
+++ /issm/trunk-jpl/jenkins/jenkins.sh	(revision 26763)
@@ -374,8 +374,20 @@
 		echo "pid: ${pid}"
 		echo '-----------------------------'
-		while [ -n "${pid}" ]; do
+		# Time out after $max_time seconds because sometimes multiple MATLAB processes get locked in race condition
+		timer=0
+		max_time=3600
+		while [[ timer -lt ${max_time} && -n "${pid}" ]]; do
 			pid=$(ps -W | grep MATLAB | awk '{print $1}')
+			timer=$((timer + 1))
 			sleep 1;
 		done
+		# Check if timer hit $max_time
+		if [ $timer -eq $max_time ]; then
+			echo "Testing timed out"
+			# Kill MATLAB processes
+			pid=$(ps -W | grep MATLAB | awk '{print $1}')
+			/bin/kill -f "${pid}"
+			exit 1
+		fi
 	else
 		wait
