F-1 students have a 60-day grace period beyond the completion date of their program and also beyond the completion date of the Employment Authorization Document. J-1 students have a 30-day grace period beyond the completion date of their program and also beyond the completion date of the J-1 Post Completion Academic Training Work Authorization.
You may not work during this grace period, but you may apply to transfer to another F-1 or J-1 academic program, or apply to a different non-immigrant status, as long as you remain in the U.S. during this process.
If you depart the U.S. during the grace period, you will be unable to re-enter in F-1 or J-1 status. You will need to have a new approved status and may need to renew or apply for a new visa stamp in order to re-enter the U.S.