Add fix for memory leak due to variable capture
Add fix for memory leak due to variable capture

Fix proposed by @kirill-gavrilyuk here:
https://github.com/slamdata/purescript-halogen/issues/586#issuecomment-501677358

slamdata/purescript-halogen,garyb/purescript-halogen