Added promises that are resolved when the menu is closed.

This is a small feature that I needed for a project that I am working on.
Here are my results; hopefully they can be useful to someone else!