From 3188cda3e47fe96822f788358b4e5710f2b79e51 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 11 Jul 2026 16:52:42 +0100 Subject: [PATCH] Fixed exit when running --- source/MainForm.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/MainForm.cs b/source/MainForm.cs index ce9a0ab..ae73db2 100644 --- a/source/MainForm.cs +++ b/source/MainForm.cs @@ -69,7 +69,17 @@ namespace CursorGuardRail protected override void OnFormClosing(FormClosingEventArgs e) { - if ((this.HideOnClose && !_requestExit) || _timer.Enabled) + // On exit requested, exit + if (_requestExit) + { + if (_timer.Enabled) _timer.Stop(); + + ClipCursor(Rectangle.Empty); + return; + } + + // Always hide instead of close, if running + if (this.HideOnClose || _timer.Enabled) { e.Cancel = true; @@ -77,10 +87,6 @@ namespace CursorGuardRail return; } - if (_timer.Enabled) _timer.Stop(); - - ClipCursor(Rectangle.Empty); - base.OnFormClosing(e); }