Play audio file after un-hold call

I have the following scenario:
a) user A (sip/desk phone) calls outside user B (mobile phone)
b) user A puts user B on hold -> user B hears an hold tone
c) user A does a call and hangs up
d) user B is un-hold and can talk to user A
e) user A transfer the call to user C (another sip/desk phone) with *2 -> user B hears an hold tone
f) user A hangs up and B and C can talk or user C hangs up and A and B can talk

Is there a way to avoid point d so user B can’t talk to user A between b and f ? Asterisk is