Stage Event

I have a requirement, where when the stage window is close it should clear all the selected prim paths.
as I know there is a method to clear all the prim path selected, but issue I’m facing right now,
how will I know when the stage window is closed? I event tried with the stage event type but not able to resolve my issue.
The way i have implemented is
I have an extension which has create_subrcription_to_pop which will be listening to stage events
but when i close the stage event im unable to know it closed, How can i resolve this problem?