anchor.diff:  handle_modified(Exit, #state{commit_delay = Delay} = State) ->
       ?error("Modify handler of a transaction process terminated abnormally: ~p",
           [Exit]),
  -    schedule_commit(Delay, modify_async(State#state{
  +    schedule_terminate(schedule_commit(Delay, modify_async(State#state{
           modify_handler_pid = undefined
  -    })).
  +    }))).
   
   %%--------------------------------------------------------------------
   %% @private
  
positive.code:     modify_handler_pid :: undefined | pid(),
      % a pid of the commit handler process
      commit_handler_pid :: undefined | pid(),
      % a reference to the message expected to trigger commit
      commit_msg_ref :: undefined | reference(),
      % a reference to the message expected to trigger terminate
      terminate_msg_ref :: undefined | reference(),
      commit_delay :: timeout(),
      idle_timeout :: timeout()
  
negative.code: schedule_commit(_Delay, #state{changes = undefined} = State) ->
      State;
  schedule_commit(Delay, #state{commit_msg_ref = undefined} = State) ->
      Ref = make_ref(),
      erlang:send_after(Delay, self(), {Ref, {commit, Delay}}),
      State#state{commit_msg_ref = Ref};
  schedule_commit(_Delay, #state{} = State) ->
      State.
  
  %%--------------------------------------------------------------------
  %% @private
  %% @doc
  %% Schedules terminate operation.
  %% @end
  %%--------------------------------------------------------------------
  -spec schedule_terminate(state()) -> state().
  schedule_terminate(#state{
      idle_timeout = IdleTimeout,
      terminate_timer_ref = undefined
  } = State) ->
      MsgRef = make_ref(),
      TimerRef = erlang:send_after(IdleTimeout, self(), {MsgRef, terminate}),
      State#state{
          terminate_timer_ref = TimerRef,
          terminate_msg_ref = MsgRef
      };
  schedule_terminate(#state{terminate_timer_ref = Ref} = State) ->
      erlang:cancel_timer(Ref),
      schedule_terminate(State#state{terminate_timer_ref = undefined}).
  
  %%--------------------------------------------------------------------
  %% @private
  