if you file H1b application before your quit PHD, you status is fine (it will be H1b pending), but you can not start work until H1b is approved. Since H1b may be denied (although it is not likely for a school job if the salary is fine), it is good to quit PHD after H1b approval.
The bottom line is, you status is fine if you quit after you submit your H1b application. But you risk is you will be out of status if H1b is denied, which is unlikely.
good luck