Metadata xattrs stays in metadata forever when app stops

Would you mind posting the code you are using? In the scenario you described, the “staging” data should hang around, but eventually be cleaned up by a background process.