Quitting Job on H1b: Max days one can stay if valid visa till 2023

Hi All,
I have a valid visa till 2023, but due to some family emergency i am planning to move back for few years to India. My schedule is to move on October 5, 2021 for some unavoidable reasons.

Now do i need to stay on my job with current employer (i have a approved I140 with them) till that date , or can i quit before October 5 (if so before how many days max)? I wanted to rest up a bit before that since my health was bit impacted because of covid.

Thanks!

You will get 60 days grace period once you resign and quit the job.