Causal inference for the expected number of recurrent events in the presence of a terminal event