#1019882: if start() and stop() were not in the same stack frame, stats.load() would crash with IndexError.
diff --git a/Lib/hotshot/log.py b/Lib/hotshot/log.py
index 47c932a..17e8b50 100644
--- a/Lib/hotshot/log.py
+++ b/Lib/hotshot/log.py
@@ -106,7 +106,10 @@
                 return what, t, tdelta
 
             if what == WHAT_EXIT:
-                return what, self._pop(), tdelta
+                try:
+                    return what, self._pop(), tdelta
+                except IndexError:
+                    raise StopIteration
 
             if what == WHAT_LINENO:
                 filename, firstlineno, funcname = self._stack[-1]