Add activity.write and save to datastore before stop

Activities that want to store something should override activity.write
.  It is called before the activity stop.