diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs
index e70570d9f..7784dd791 100644
--- a/Terminal.Gui/Core/Application.cs
+++ b/Terminal.Gui/Core/Application.cs
@@ -1134,6 +1134,7 @@ namespace Terminal.Gui {
_initialized = false;
mouseGrabView = null;
_enableConsoleScrolling = false;
+ lastMouseOwnerView = null;
// Reset synchronization context to allow the user to run async/await,
// as the main loop has been ended, the synchronization context from
diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs
index 08952f48b..23dc882ed 100644
--- a/Terminal.Gui/Core/Toplevel.cs
+++ b/Terminal.Gui/Core/Toplevel.cs
@@ -984,6 +984,13 @@ namespace Terminal.Gui {
{
return MostFocused?.OnLeave (view) ?? base.OnLeave (view);
}
+
+ ///
+ protected override void Dispose (bool disposing)
+ {
+ dragPosition = null;
+ base.Dispose (disposing);
+ }
}
///
diff --git a/UnitTests/TopLevels/ToplevelTests.cs b/UnitTests/TopLevels/ToplevelTests.cs
index 3df27386b..6e1f2a877 100644
--- a/UnitTests/TopLevels/ToplevelTests.cs
+++ b/UnitTests/TopLevels/ToplevelTests.cs
@@ -1163,6 +1163,8 @@ namespace Terminal.Gui.TopLevelTests {
│ this. │
│ │
└────────────────────────────┘", output);
+
+ Application.End (rs);
}
}
}
\ No newline at end of file