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: schedule_commit(_Delay, #state{changes = undefined} = State) ->
      State;
  schedule_commit(Delay, #state{commit_msg_ref = undefined} = State) ->
      State#state{commit_msg_ref = schedule_msg(Delay, {commit, Delay})};
  schedule_commit(_Delay, #state{} = State) ->
      State.
  
  %%--------------------------------------------------------------------
  %% @private
  %% @doc
  %% Schedules terminate operation if there are no pending requests, uncommitted
  %% changes and modify/commit handlers running.
  %% @end
  %%--------------------------------------------------------------------
  -spec schedule_terminate(state()) -> state().
  schedule_terminate(#state{
      requests = [],
      changes = undefined,
      modify_handler_pid = undefined,
      commit_handler_pid = undefined,
      idle_timeout = IdleTimeout
  } = State) ->
      State#state{terminate_msg_ref = schedule_msg(IdleTimeout, terminate)};
  schedule_terminate(#state{} = State) ->
      State.
  
  %%--------------------------------------------------------------------
  %% @private
  %% @doc
  %% Wraps message with a reference tag and sends after delay to the calling
  %% process. Returns reference tag.
  %% @end
  %%--------------------------------------------------------------------
  -spec schedule_msg(timeout(), any()) -> undefined | reference().
  schedule_msg(infinity, _Msg) ->
      undefined;
  schedule_msg(Delay, Msg) ->
      Ref = make_ref(),
      erlang:send_after(Delay, self(), {Ref, Msg}),
      Ref.
  
  %%--------------------------------------------------------------------
  %% @private
  
negative.code: %%--------------------------------------------------------------------
  -spec handle_modified(Exit :: any(), state()) -> state().
  handle_modified({modified, false, Data}, #state{} = State) ->
      schedule_terminate(handle_modified(
          {modified, {true, undefined}, Data}, State
      ));
  handle_modified({modified, {true, NextChanges}, Data}, #state{
      module = Module,
      changes = Changes,
  