My son (also fifth grade) has similar issues. It is draining and stressful. What helps is therapy (my husband and I alternate weeks taking him) that is both play and talk-based, a supportive school system, and medication (diagnoses ADHD and we literally just started the medication route this month...been trying to hold it off for years). We talk and listen when he needs it.
We use natural consequences. For example, my son often shuts down at school and refuses to do his work. So I have his teachers send all this work home and he has to finish it before he gets to do what he wants to (electronics, playing outside, etc). I don't say "you didn't behave at school so you don't get to watch youtube tonight!" But he knows that in order to do that he needs to finish his work. I will help him as needed.
It sucks so bad, it's hard to be happy when your kid isn't. Hang in there mama!