presto-main/src/main/java/io/prestosql/execution/QueryStateMachine.java/QueryStateMachine/transitionToFinished
class QueryStateMachine:    private void transitionToFinished()
    {
        cleanupQueryQuietly();
        queryStateTimer.endQuery();

        queryState.setIf(FINISHED, currentState -> !currentState.isDone());
    }