fix #843 Trim deployment at write time

Simply perform Trimming (purging) deployments at MarkComplete (success or failed) time.