Your visa remains valid if you are still enrolled in school. If you leave the country during the school year/during the school holidays, a member of the International Student Centre must sign your I20 in order to allow you re-entry into the United States

If you finish your programme and are no longer enrolled in the university, your visa will no longer be valid (even if the dates are still good).