# Problem when closing a window programmatically

**URL:** https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291
**Category:** AlterNET UI Support
**Created:** [May 20, 2026, 9:38pm UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291 "2026-05-20T21:38:47Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![JohnnyG](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/johnnyg/32/93_2.png) [@JohnnyG](https://forum.alternet-ui.com/u/JohnnyG)
#### Post date: [May 20, 2026, 9:38pm UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/1 "2026-05-20T21:38:48Z")

</div>

Perhaps my understanding isn’t correct, but after reading the Window section in the docs I would expect calling the window.Close() method should result in the following.

- **If WindowCloseAction is None**
  - Window stays open, Closing and Closed events are not fired

- **If WindowCloseAction is Hide**
  - Windows hides, Closing and Closed events are not fired

- **If WindowCloseAction is Disposed**
  - Windows is disposed, Closing and Closed events are fired

But this isn’t quite what is happening. I have tried this on Windows in Visual Studio and MacOS (intel) in Rider with the following results.

- **When calling windowClose():**
  - **If WindowCloseAction is None**
    - Works as expected

  - **If WindowCloseAction is Hide**
    - Closing event is fired, but otherwise works as expected

  - **If WindowCloseAction is Disposed**
    - Window hides but is not disposed
    - Closed event is not fired but Closing event is fired

- **When Clicking on close box in corner instead of calling Close()**
  - **On Windows:** Closing event is not fired, though Closed is fired and window is disposed
  - **On MacOS:** Works as expected, Closing and Closed are fired and window is disposed

---

<div class="post-metadata">

### Author: ![generalloki](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/generalloki/32/83_2.png) [@generalloki](https://forum.alternet-ui.com/u/generalloki)
#### Post date: [May 28, 2026, 4:12am UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/2 "2026-05-28T04:12:10Z")

</div>

Thank you for your message. I will test the behavior of the `Close` method and let you know the results as soon as possible.

---

<div class="post-metadata">

### Author: ![generalloki](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/generalloki/32/83_2.png) [@generalloki](https://forum.alternet-ui.com/u/generalloki)
#### Post date: [May 28, 2026, 4:41am UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/3 "2026-05-28T04:41:54Z")

</div>

When `WindowCloseAction` is set to `Hide`, the `Closing` event is fired, and this is the expected behavior. This event allows you to perform checks to determine whether the window close operation should be allowed. I will review the documentation and add some notes there.

---

<div class="post-metadata">

### Author: ![generalloki](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/generalloki/32/83_2.png) [@generalloki](https://forum.alternet-ui.com/u/generalloki)
#### Post date: [May 28, 2026, 4:56am UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/4 "2026-05-28T04:56:27Z")

</div>

I confirm that the window is not disposed when `Close` is called with `WindowCloseAction.Dispose` on the MSW platform. This is a bug, and we will address it in upcoming builds. Until it is fixed, you can call `SendDispose` to close and dispose of the window.

---

<div class="post-metadata">

### Author: ![generalloki](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/generalloki/32/83_2.png) [@generalloki](https://forum.alternet-ui.com/u/generalloki)
#### Post date: [May 28, 2026, 5:32am UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/5 "2026-05-28T05:32:46Z")

</div>

When clicking on close box in corner, Closing/Closed events are fired on MSW. There is a Window related demo in Samples/Window Properties. It logs Closing/Closed events. You can check there and see log items when close box in corner is clicked.

---

<div class="post-metadata">

### Author: ![JohnnyG](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/johnnyg/32/93_2.png) [@JohnnyG](https://forum.alternet-ui.com/u/JohnnyG)
#### Post date: [May 29, 2026, 1:45pm UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/6 "2026-05-29T13:45:30Z")

</div>

Thank you for looking into this. By the way, AlterNET UI is truly amazing!!!

---

<div class="post-metadata">

### Author: ![generalloki](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/generalloki/32/83_2.png) [@generalloki](https://forum.alternet-ui.com/u/generalloki)
#### Post date: [July 7, 2026, 8:12am UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/7 "2026-07-07T08:12:04Z")

</div>

I think we fixed issues related to Window.Close method in 1.1.0. Please try it and let me know whether it is ok now.

---

<div class="post-metadata">

### Author: ![JohnnyG](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/johnnyg/32/93_2.png) [@JohnnyG](https://forum.alternet-ui.com/u/JohnnyG)
#### Post date: [July 21, 2026, 7:17pm UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/8 "2026-07-21T19:17:04Z")

</div>

It seems to be working fine on Windows. However, Alternet-UI 1.10 projects do not run on MacOS (Intel). There is a System.EntryPointNotFoundException in Main() when creating a new Application instance.

System.EntryPointNotFoundException: Unable to find an entry point named ‘Font\_CreateFontRef\_’ in shared library ‘Alternet.UI.Pal.dll’.  
at Alternet.UI.Native.Font.NativeApi.Font\_CreateFontRef\_(GenericFontFamily genericFamily, NativeStringSpan& familyName, Single emSizeInPoints, FontStyle style)  
at Alternet.UI.Native.Font.CreateFontRef(GenericFontFamily genericFamily, NativeStringSpan familyName, Single emSizeInPoints, FontStyle style)  
at Alternet.UI.WxControlHandler.\<\>c\_\_DisplayClass41\_1.b\_\_0(NativeStringSpan span)  
at Alternet.UI.StringUtils.\<\>c\_\_DisplayClass32\_0.b\_\_0(IntPtr ptr, Int32 length)  
at Alternet.Skia.SkiaHelper.InvokeWithUTF8Span(ReadOnlySpan`1 input, Action`2 action)  
at Alternet.UI.StringUtils.InvokeWithNativeText(ReadOnlySpan`1 text, Action`1 callback)  
at Alternet.UI.WxControlHandler.GetFontRef(Font value)  
at Alternet.Drawing.WxFontFactoryHandler.SetDefaultFont(Font value)  
at Alternet.UI.AbstractControl.set\_DefaultFont(Font value)  
at Alternet.UI.Window.UpdateDefaultFont()  
at Alternet.UI.App..ctor(IApplicationHandler handler)  
at Alternet.UI.Application..ctor(IApplicationHandler handler)  
at Alternet.UI.Application..ctor()  
at AlternetUIApp2.Program.Main(String args) in ‘path to project’

---

<div class="post-metadata">

### Author: ![generalloki](https://forum.alternet-ui.com/user_avatar/forum.alternet-ui.com/generalloki/32/83_2.png) [@generalloki](https://forum.alternet-ui.com/u/generalloki)
#### Post date: [July 22, 2026, 7:41am UTC](https://forum.alternet-ui.com/t/problem-when-closing-a-window-programmatically/291/9 "2026-07-22T07:41:57Z")

</div>

Alternet.UI 1.1.0 build is only for arm cpu. I think we will include Intel version in the new release.
