Properly record timed out builds

This corrects a logic error where timed out builds were recorded as
ABORTED. They should be recored as TIMED_OUT instead. Update the tests
which asserted the incorrect result as well.

Change-Id: Ibc07a87a42dbd8de3ae78dfeedc5c8260c9c0153
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 678b957..3919418 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -264,7 +264,7 @@
         self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
         self.waitUntilSettled()
         build = self.getJobFromHistory('timeout')
-        self.assertEqual(build.result, 'ABORTED')
+        self.assertEqual(build.result, 'TIMED_OUT')
         build = self.getJobFromHistory('faillocal')
         self.assertEqual(build.result, 'FAILURE')
         build = self.getJobFromHistory('check-vars')
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 571f3ee..c1e2d48 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -57,7 +57,11 @@
         if self._running:
             self.timed_out = True
             self.function(*self.args)
-        self.timed_out = False
+        else:
+            # Only set timed_out to false if we aren't _running
+            # anymore. This means that we stopped running not because
+            # of a timeout but because normal execution ended.
+            self.timed_out = False
 
     def start(self):
         self._running = True