As teacher, create a quiz and set a time limit, a close date and set When time expires to Allow a grace period to submit, but not change any responses. Set Submission grace period to a suitable amount of time to let you do the tests below.
1. As student, start a quiz attempt and answer some questions. Then lot out of Moodle.
2. Wait until the time limit has expired, but before the Quiz cron has run, then log back in as a teacher, and confirm that the attempt is still shown as In-progress.
3. Log in as a student, and go to the quiz info page. This will cause the quiz attempt to be automatically moved to the Overdue state.
4. Click the "Continue last attempt" button and you will be taken to the summary page, where you are told you can still submit up to a certain time.
5. Do not submit the attempt, wait for the grace period to expire, refresh the page and confirm that attempt is set to "Never Submitted".
6. Login as teacher and check that that the attempt is set to "Never submitted" and has not been graded.