Yes. Semiautos can discharge when the bolt or slide is closed.
This can be caused by several factors, the most common being pilot error. If one is not paying attention when charging a semiauto and 'twitches' the trigger when the pistol slams shut, the gun will fire. What is confusing is the shooter may or may not realize what he did, and quite honestly be unaware.
The second commonest factor in my mind is a defect in the pistol. This varies with the type, brand and age/use history of the pistol in question. One of my Savage .32 Autoloaders will double on occasion, or fire when he first round is fired. (I found this on the second occasion I fired it. Until I can figure out how to fix it, it will sit in the display and look cool.) From what I can see, the sear-striker notch connection is not quite right. Other factors include 'stuck' firing pins, the sloppy assembly noted by Mr. Watkins, and filth. No doubt other problems occur as well.
High primers get mentioned from time to time. I think a high primer is a fairly unlikely cause. I've experimented with high primers in a Government Model pistol to see if I could make it slam fire. (On a range with no other shooters and I only loaded one round at a time.) I could not make it happen. In fact, once I gave up on the slam fire, I had to drop the hammer on the prepared cartridge twice, once to fully seat the primer and again to fire it.
However, the spirit of Murphy is alive, well and still conniving; so don't bet your hand, knee or dog it won't happen. (I am reminded of comments like "Oh, that'll NEVER happen", "According to [insert noted authority here] it can't happen" and "Watch this! Hold my beer...")
One more thing: I have had at least one discharge while loading by placing a round directly in the chamber and letting the slide fall. Most autoloaders are designed to function by stripping a round from the magazine. That is how the extractor and rim connect properly, and it cushions the 'slam' of the closing slide. I always load from a magazine.