wxWidgets app hanging when using modal dialog

  c++, wxwidgets

I have a simple wxWidgets application where I create a wxMessageDialog and then show it.

For some reason when I return from the startup method the app will then hang.

Here is the code:

bool App::OnInit()
    wxMessageDialog* dialog = new wxMessageDialog(NULL, "Message", wxMessageBoxCaptionStr, wxOK | wxCENTER | wxDIALOG_NO_PARENT);

    return true;

I have tried calling EndModal() on the dialog but that makes no difference.
I did see a question referencing this situation in Python but using wxDIALOG_NO_PARENT has made no difference to the behaviour

Any ideas what could the problem be?

Source: Windows Questions C++