He has done ZERO homework and is getting straight F's in class. His highest grade is a 52. He just doesnt care, and if I take anything away from him he drives me so insane I just have to give it back. He says hes bored in school, but even after moving him to advanced classes, hes still bored. He just doesnt care.
Here's something you might consider.
Sit him down and very seriously tell him that you have been thinking about what he has been telling you, and you will give him the chance to prove what he said; that he really doesn't need to go to school any more.
Explain to him that the purpose of school is to prepare him for getting a job so he can support himself. Does he need to continue going to school or can he stop? Tell him that if he is able to get a job making enough money that he can support himself, he can stop going to school. Sit down and figure out how much his rent is going to be. His food. Clothing. Extras. He'll get a better deal at home than he would outside, but let him consider all the alternatives.
Tell him everybody needs to work to get what they need. That's just the way life is. It isn't fair for some to work and others not to have to. Kids work in school. Adults work at a paying job. If he wants the privileges of being an adult (choosing not to go to school) he needs to prove that he is able to handle adulthood. If he can make enough money to support himself now then his complaints have merit.
If he makes an effort to participate, you have something to work with. Make deals with him. If he is willing to work, but truly doesn't consider school worth his time, let him try it out (you may have to wait for summer to actually implement this, but you can lay the groundwork now). It's a pretty safe bet that he won't be able to earn enough that he doesn't have to supplement his income with school time on the side, but let him find that out himself.
If you get more of the sulky, whiny same, then he is just trying to get away with living a life where he doesn't have to do anything he doesn't "want to". Obviously, this is a very bad sign and you will have a tough road ahead of you to convince him that he cannot skate through life expecting to get whatever he wants without having to work for it.
Does he do chores? If not, that may have been a contributing factor. My kids know if they want things they have to work for them. My son does the dishes and my daughter does the laundry; this is how they earn the $40 we pay each month for them to have smart phones.
As adults most of us know that life isn't about only doing the fun things. We have to do the un-fun things in order to earn to fun. School is his job. Treat it like that.
When my kids were very young we implemented the "golden penny" system. They received pennies spray painted with gold for everything they did worthy of being rewarded. brushing their teeth well, cleaning their rooms, getting good grades. Then, whenever they asked me for something "Mommy...I want that toy..." I just told them it would cost x golden pennies; did they have enough? If so, they got the toy. If not, they needed to save up. It eliminated any sort of whining at me in the stores because they knew what they needed to do in order to get what they wanted.
Obviously your son is too old for golden pennies, but introducing him to the idea that everything in life that he wants is going to have a cost may help. My rule of thumb is if is it something I want them to have (nutritious food, sensible clothing, etc), they get it without paying. If they ask for it, usually they have to "pay" for it. Maybe if you treat school like a job and he has to earn all his treats and toys, being paid according to his grades, that would give him an actual goal worth working toward. It may seem counterintuitive, but my son was actually happier having to earn his computer time than he was when he just got it for free. It's a fact of human nature that we don't value the things we get for free as much as we value things we pay for.
I will admit that it hasn't worked as well as I would have wished on my twelve year old son. He would rather play computer games and do without all the "cool stuff" he wishes he could have (anything Star Wars related, every new game that he finds on eBay, etc) than get a job (I offered to help him create a flyer to distribute in the neighborhood advertising his services as a dog walker or lawn mower) but it has completely eliminated the "aww, Mom, pleeeezzzse" factor and he did spend the entire day taking everything out of our garage, hosing and scrubbing the floor, and putting it all back in order to earn the $100 deductible for replacing the cell phone after he broke it for the second time. So at least he's moving in the right direction :)
There are people (other than your child) who are of the opinion that middle school is purely about wasting time, for keeping kids out of the workforce for three more years. Google "middle school waste of time" and you will see what I mean. As you read the articles, you will find that some of the writers are, or have been, middle school teachers. The idea can't be simply written off as crack pottery.
However, the truth is that unless home schooling is an option (and in this case I would probably not recommend it), he will have to complete middle school.
At 13, he is transitioning from child to adult. He has established that he has a stronger will than you ("he drives me so insane I just have to give it back"), so it is not going to be easy.
It sounds to me like your son needs something real, with real rewards and consequences. I'll borrow and example from a Japanese childrens cartoon, "Hunter x Hunter", which follows the adventures of two boys, Gon and Killua as they seek to become Hunters. Co-incidentally by this point in the story, they are both 13 years old.
In one of the episodes of the Greed Island arc, Bisky is trying to teach the boys to remain aware even when they are asleep. She rigs up a block and tackle and has the boys hold a rope attached to a large rock hanging over their own heads as they sleep. If they let go of the rock, the consequences are as natural as gravity (they get bonked and have to start over). If they don't get bonked, then they have learned the skill.
No I don't recommend this precise treatment for your boy (although you have my permission to daydream of it), but the concept is that they had a real goal that meant something in society at large, a skill that needed to be learned to achieve that goal, a reward was inherent in mastering the skill, and the consequences of failure were immediate, (somewhat) natural, and directly under their control.
While it is true that as an adult, a lot of my work is boring, it is something that people need (or they wouldn't pay my billing rates), I get a real reward from it (food, housing, vehicle), and real consequences of failure (lost customers, lost income, etc).
No one wants to read seventh or eighth grade english papers or math assignments after they are graded, and he plays video games because he is bored.
My daughter complained in 5th grade that her math was too easy, so she went to her math teacher and asked for enrichment activities. Over a period of about 4 weeks he tried to find exercises at her level of understanding. Finally, partially out of frustration, he gave her a binomial division problem. When she gave him her (correct) answer, he informed her he couldn't help her beyond that.
If your son is truly that advanced, then it is possible that the middle school can't cater to his scholastic needs. However, if there is a real (not contrived) reward for exercising discipline in school work, he may choose that route. For my daughter, the discovery of the world of videography, and the opportunity to be part of a the school videography program, provided the impetus for her to raise her grades and keep them up.