correctly switching to next level or quit if just finished end level