Cleanup closure before sending to remote