Welcome to the forum, and there has been a lot of discussion about this. Suggest you take some time and look at the various out of battery (or OOB) related discussions here.
M&P 15-22.. the 23rd shot...
Major Malfunction on M&P 15-22
M&P 15-22 goes boom...not good
That will keep you busy for awhile