Simplify handling the almostEnding flag