Fix duration being incremented after a build/job is finished

This resolves issue https://github.com/travis-ci/travis-ci/issues/1406.