what's the best practise to close parent (modal) window from child componen

I have a customcomponent (A) and it contains a form. The form has a “cancel” button.
The (A) is embedded into a (Modal) window (W).

If the “cancel” button is clicked, I want to close the Modal Window (W). It’s do-able if I pass the reference of the (W) to the (A)…and I can use UI.getCurrent and then close the (W).

But this reduces the re-usability of (A). I want (A) to give a signal to the parent (W in this case) that “I’m done” and it’s up to the parent (W here) to decide what to do.

This can be done by implementing a event notifier/listener…but do I need to do it by myself. Or this kind of event already exist…and I only need to fire it from the (A).