Fix #204: Leak in CustomDialog

Also included test method inside CustomDialogSample. This is a button (and thus obvious), can be made less obvious if desired.