How to delete a pubsub subscription if client gets logout or after a certain period

I am subscribing the openfire using strophejs, but how to delete the subsription if the user session are connection gets closed or after certain time period. If I am subscribing from same JID it is creating multiple subscriptions and not getting deleted. So, how can I apply the above two conditions for pubsub subcription.

I don’t think such functionality exists. Can you instead query for existing subscriptions, before making a new one?