you can't prevent maggots. seriously, forget about them. they'll do you no harm. I worried about them at first too, thinking I was gonna kill/poison anyone who i shared my shrooms with, but really, it's just another protein source in the end, and that's coming from a vegetarian of 20+ years ;p
but if you really wanna pursue reducing them b'cos they annoy you for whatever reason, then you can get rid of as many as poss by lying them out on brown paper [will post pics of mine in a mo, if i can be arsed after writing this] ... that's the best way to flush the buggers out and so you can actually SEE them as they inevitably crawl their way out of the cap, wondering what the fuck is going on, and then promptly DAI on the the paper due to dehydration/exhaustion/whutthefuckeva. you can pick em off with tweezers from the cap, or paper if you really wanna be anal about it. I have on a couple of occasions. they pretty much work their way out after about an hr of being laid out, in my experience
and if youre gonna start worrying about maggots, really ... there's a fuckton of other shit you should be worrying about first before maggots ... like eating sheep/cow/horse shit, what the flies have eaten and then puked back onto the cap surface, whut's in the soil, and therefore in your shrooms, etc etc ...
my advice? forget about it all. and washing em wont make any difference either. you aren't gonna catch shroom AIDS or CANCER, and I'm still alive, and I've tripped on these things hundreds of times, picked, dried and processed by myself, without too much fannying around being anal. Push all that semi-irrational fear of 'possible, but very-fucking-unlikely' outta your mind and just neck 'em and enjoy

... and for the record, I'm a pretty prissy, neurotic specimen most of the time .. I just know from experience, maggots/poop etc wont harm you in this situation
the question of maggots just got me searching through all my old field pics, and drying, and most of them seem to of been taken in early Novemeber. and now Im fucking salivating at just how resourceful this new field I found actually was, and I can't wait for the next few months