The best way to prevent it is to not foil!
Seriously though, don't try to work the meat on the barrel. I like to keep a small table next to my uds. Just pull the grate out, set it on the table, and quickly put the lid back on. Then you can take your time and foil the butt. No flare ups, no big temp spikes, and no loss of hair!
Btw, I like to use a couple of bricks turned on their sides to place the grate on. That way your grate is not sitting directly on your table.