Close the popup window only after the callbacks are done
Merge pull request #2 from macu/master

Close the popup window only after the callbacks are done