@killyourfm I only have a partial solution. If it happens you can ctrl-shift-n to reopen the last closed window.
There is also a warning you can set up when you try to close multiple windows, but I don't think there is a specific one for pinned tabs.