QTBUG-43257, but I still have a similar issue with 5.4.1.
I've attached an example.
When the application doesn't have the focus (e.g. my Qt application is behind another application) right clicking on it will quickly show the context menu, then close it.
I've attached a small example project to reproduce the problem.
It will immediately return from QMenu::exec
If the application has the focus, it is working as expected.