He didn't know what was happening but managed to get into contact with Shield or with Bruce who told him he had to lock down the tower to stop them escaping and harming the public.
He managed to do it and I think they found a sound frequency to knock them out of it.
I remember that Peter was traumatized by what had happened by none of the Avengers remembered and Shield told Peter to not mention anything and get on with it even if he was struggling or that they'd kick him off the Avengers.
Any help finding this fic would be greatly appreciated! I'm pretty sure it's on Ao3 as well but am can't seem to find it.
In the Home by aloneintherain