I have seen this happen if there are both content and question pages in the lesson with minimum number of questions. See this forum https://moodle.org/mod/forum/discuss.php?d=219905 . Our work aroumd was to take the table of contents out of the lesson so students couldn't by pass the other question pages and go to the end.
Paula