I used uniqueinstance in my app and while it generally worked OK, I found that if the app crashed, it would sometimes continue reporting itself as OK but not otherwise responding. This was a particular problem on the Mac where it was sometimes very hard to clean up after a crash.
So, instead, I now use the
https://wiki.freepascal.org/SimpleIPC model, its heaps more reliable and much more flexible, you define what messages you want to pass between processes, very easy to add a message that says "OK you, close now !".
And it obviously solves the unique problem as well, as the app starts up, it tries to find another SimpleIPC server, if not found, it becomes the server.
Davo