If you use exec to show your dialog, you know it has ended when the method returns.
As for your other question, depending on what you want to do, you can use the close method to emit a custom signal for example but you don't give enough context to answer properly.