The following will remove any areas greater than 8000 pixels:
M3 = M2 & ~bwareaopen(M2,8000);
Another option would be to use regionprops() to get the area of every mask and then remove [stats.Area]>8000, but I think the above 1-line solution is cleaner.
