anchor.diff:      {noreply, State3};
   handle_info(inactivate, #state{} = State) ->
       {noreply, check_inactivate(State#state{inactivate_timer = undefined})};
  +handle_info({check_terminate, ReplyTo} = Msg, #state{
  +    keys_to_inactivate = ToInactivate,
  +    disc_writer_pid = Pid} = State) ->
  +    case allow_terminate(State) of
  +        true ->
  +            catch gen_server:call(Pid, terminate, infinity), % catch exception - disc writer could be already terminated
  +            datastore_cache:inactivate(ToInactivate),
  +            gen_server:reply(ReplyTo, ok),
  +            {stop, normal, State};
  +        false ->
  +            erlang:send_after(?TERMINATE_CHECK_INTERVAL, self(), Msg),
  +            {noreply, State}
  +    end;
   handle_info(Info, #state{} = State) ->
       ?log_bad_request(Info),
       {noreply, State}.
  
positive.code: 
  %% @private
  -spec schedule_flush(state(), non_neg_integer()) -> state().
  schedule_flush(State = #state{cached_keys_to_flush = Map}, _Delay) when map_size(Map) == 0 ->
      State;
  schedule_flush(State = #state{flush_timer = OldTimer}, Delay) ->
      case {OldTimer, Delay} of
  
negative.code:     #state{master_pid = MasterPid, ha_master_data = HAData, ha_failover_requests_data = FailoverData} = State) ->
      ha_datastore_master:forget_backup(Inactivated, HAData),
      FailoverData2 = ha_datastore_slave:report_keys_flushed(MasterPid, Inactivated, FailoverData),
      State#state{ha_failover_requests_data = FailoverData2}.
  
  -spec allow_terminate(state()) -> boolean().
  allow_terminate(#state{
      requests_ref = undefined,
      cached_keys_to_flush = ToFlush,
      keys_in_flush = KiF,
      keys_to_expire = ToExpire
  }) when map_size(ToFlush) =:= 0, map_size(ToExpire) =:= 0, map_size(KiF) =:= 0 ->
      true;
  allow_terminate(_) ->
      false.