How to properly clear custom asset reference when close custom asset editor?

Hello, I’m developing my own touch interface system and I’m using Slate to edit my custom asset with custom editor. Everything works for the moment as I wish, my custom asset is open, modified and saved without problem in my custom editor.

The problem is that my custom asset is still referenced in memory when I close the custom editor and if I want to open my custom editor again (with a double click on the asset for example), I get the following error and the custom asset editor does not open :

=== Handled ensure: ===
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           Ensure condition failed: ToolkitHost.IsValid() [File:D:/Build/++UE4/Sync/Engine/Source/Editor/UnrealEd/Private/Toolkits/BaseToolkit.cpp] [Line: 130]
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           Stack: 
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe99e26849 UE4Editor-UnrealEd.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe99a64afc UE4Editor-UnrealEd.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe99a061a5 UE4Editor-UnrealEd.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe99a1f44c UE4Editor-UnrealEd.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe83d58fe7 UE4Editor-ContentBrowser.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe83d1688f UE4Editor-ContentBrowser.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe83d622ad UE4Editor-ContentBrowser.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe83d1461d UE4Editor-ContentBrowser.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe83d11037 UE4Editor-ContentBrowser.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe83d74077 UE4Editor-ContentBrowser.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe83d6271b UE4Editor-ContentBrowser.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe9b550f9e UE4Editor-Slate.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe9b5d53e2 UE4Editor-Slate.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe9b5be68a UE4Editor-Slate.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffe9b5b1ad9 UE4Editor-Slate.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffebcd27f62 UE4Editor-ApplicationCore.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffebcd15c87 UE4Editor-ApplicationCore.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffebcd2a619 UE4Editor-ApplicationCore.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffebcd117d0 UE4Editor-ApplicationCore.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007fff1820e858 USER32.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007fff1820e299 USER32.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ffebcd2bb34 UE4Editor-ApplicationCore.dll!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ff7ea0168c4 UE4Editor.exe!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ff7ea02ba7c UE4Editor.exe!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ff7ea02bb5a UE4Editor.exe!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ff7ea03e31d UE4Editor.exe!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007ff7ea04145a UE4Editor.exe!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007fff18c77034 KERNEL32.DLL!UnknownFunction []
Tue Mar 29 12:09:51 CEST 2022 Error        LogOutputDevice           [Callstack] 0x00007fff198e2651 ntdll.dll!UnknownFunction []

Has anyone ever encountered this error when designing a plugin? Do you think this error is related to the asset which is still referenced in memory?

Problem solved! It was not related to my custom asset but to my custom editor. In one of my widgets, I had a variable that referred to my custom editor and it was of type TSharedPtr instead of TWeakPtr which was causing the reopening issue.