Like it says in the first line of the documentation, EndDialog
ends modal dialogs. Your dialog is not modal, so EndDialog
is the wrong function. The documentation for CreateDialogIndirectParam
says
To destroy the dialog box, use the DestroyWindow function.