leave the country to apply H1 visa after I-485 getting denial,if you hold H1,you can stay here to continue your work as a H1 holder.