I am not a coder, but I don't think the explosion code is able to handle blocks being deployed while it's calculating which blocks are getting destroyed.
In the meantime, if you're having trouble with people not closing doors, a reinforced door operated with a pushbutton on the outside and a pressure plate on the inside works wonders. If you want to get fancy, make a mantrap, which is a corridor with two concrete doors on either side, one open, one closed, and toggled by a T Flip-Flop. The idea is that both doors cannot be open at the same time, and the whole system is toggled by push buttons. If you somehow manage to get a creeper inside the mantrap, that's when you activate the uninsulated HV cable you have stashed under the floor to fry that sucker alive.
But as for the concept of deployable construction foam to use as a trap, I think you're onto something. Perhaps make it triggerable by redstone as well.