anchor.diff:      tp_router:update_process_size(Pid, maps:size(NewKeys)),
       State2 = State#state{cached_keys_to_flush = NewKeys},
       {noreply, schedule_flush(State2)};
  +% Standard termination request
   handle_call(terminate, _From, #state{
  -    requests_ref = undefined,
  -    cached_keys_to_flush = #{},
  -    keys_to_expire = #{},
       keys_to_inactivate = ToInactivate,
       disc_writer_pid = Pid} = State) ->
  -    catch gen_server:call(Pid, terminate, infinity), % catch exception - disc writer could be already terminated
  -    datastore_cache:inactivate(ToInactivate),
  -    {stop, normal, ok, State};
  -handle_call(terminate, _From, State) ->
  -    {reply, working, State};
  -handle_call({terminate, Requests}, _From, State) ->
  -    State2 = #state{
  -        keys_to_inactivate = ToInactivate,
  -        disc_writer_pid = Pid} = handle_requests(Requests, false, State), % TODO - VFS-6169 Handle failover and proxy requests
  -    catch gen_server:call(Pid, terminate, infinity), % catch exception - disc writer could be already terminated
  -    datastore_cache:inactivate(ToInactivate),
  -    {stop, normal, ok, State2};
  +    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),
  +            {stop, normal, ok, State};
  +        false ->
  +            {reply, working, State}
  +    end;
  +% Termination request during node shutdown
  +handle_call({terminate, Requests}, From, State) ->
  +    State2 = handle_requests(Requests, false, State), % TODO - VFS-6169 Handle failover and proxy requests
  +    case handle_call(terminate, From, State2) of
  +        {reply, working, State} ->
  +            erlang:send_after(?TERMINATE_CHECK_INTERVAL, self(), {check_terminate, From}),
  +            {noreply, State2};
  +        Other ->
  +            Other
  +    end;
   handle_call(?SLAVE_MSG(Msg), _From, #state{ha_master_data = Data} = State) ->
       Data2 = ha_datastore_master:handle_slave_lifecycle_message(Msg, Data),
       {reply, ok, State#state{ha_master_data = Data2}};
  
positive.code:         remote_node = RemoteNode, remote_requests_processing_mode = RemoteRequestsProcessingMode} =
          ha_datastore_slave:qualify_and_reverse_requests(Requests, Mode),
      gen_server:reply(From, {RemoteRequestsProcessingMode, RemoteNode}),
      State2 = handle_requests(LocalRequests, false, State#state{requests_ref = Ref}),
      State3 = case RemoteRequestsProcessingMode of
          ?DELEGATE ->
  
negative.code:     {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}.
  