It’s important to let the teacher know ahead of time that this kind of thing is hard for your kid and why. They have lots of students and may not specifically remember that your child has a 504 or whatever. Then the teacher can help by setting up a work group with helpful peers, providing structure, checking in frequently, making sure breaks are built in, or whatever. That way your child can learn to manage these situations as they can’t all be avoided.
Don’t worry about the grade unless it’s going on a high school transcript for college and is a really low grade. Otherwise, grades don’t matter much, except in the moment. You won’t care what the grade was in the future.