How does timeout for sensors really work?

I want to use the timeout in a copy sensor, but it is not working as expected. My temp_object_change is stalled for hours on a old value, instead of going down to zero. From the documentation and examples I read, I thought this would work.

Note: I do not want to use heartbeat, as this send values without looking is something was sent just minutes ago.

sensor:
  - platform: mlx90614
    update_interval: 30s    
    object:
      id:   temp_object
      filters:
        - delta: ${delta_send_object}
        - throttle: 1minutes   

  - platform: copy
    source_id: temp_object
    id: "temp_object_change"
    unit_of_measurement: "°C/h"
    filters:
      - lambda: |-
          static float last_value = 0;
          static float last_time = 0;
          float time   = (float) millis(); 
          if ((last_time == 0)|( time <= last_time )){
            last_value = x;
            last_time  = time;
            return {};
          }
          float change = ( ( x - last_value ) / ( time - last_time ) ) * 1000 * 60 * 60;
          last_value = x;
          last_time  = time;
          return change;
      - timeout:
          timeout: 10minutes
          value: 0          
      - exponential_moving_average:
          send_every: 1          

I am not familiar with the use of a timeout in filters but more in actions.
Here is a working example

            - if:
                condition:
                  micro_wake_word.is_running
                then:
                  - micro_wake_word.stop:
                  - wait_until:
                      condition:
                        not:
                          micro_wake_word.is_running
                      timeout: 5s

But if I understand well you want go the value back to zero.
Maybe it is a solution to first set the value to zero and then do your calculation to fill the value.

And why you do this

          last_value = x;
          last_time  = time;

At the start they are set to 0 and local to this call only and just before the return you assign a new value to them without further using them

I think you want the timeout as the last filter.

Putting timeout last does not solve the situation, unfortunately. I guess I will be using heartbeat in the source sensor for now.

@AshaiRey: I use the variables - on the 2nd to nth time the code is called. Also the code should take care about the millis() overflow at ~ 50 days. It is intentional, that after a reboot the state is undefined.