Destroy LayerBuffers before dropping them

This fixes a potential pixmap leak and task failure when the LayerBuffer is dropped (#1187).

I wasn't able to reproduce the failure using the steps from #1187, but based on the stack trace I think this is the correct fix.  Alternately, would it make sense to `impl Drop for LayerBuffer`?