Look in the variables window and keep an eye on the content of LastClosedFinderWindow and ClosedFinderWindowList.
If it was me, I'd probably open and then close about twenty finder windows, just to populate the variables, then test from there. From the looks of the error you're getting, LastClosedFinderWindow is empty when it shouldn't be. By keeping an eye on the variable contents in real time, you might get an idea about what's not playing ball...
Found a strange issue that I don't think existed when we first had this discussion.
Let's say I open a new Finder window, which defaults to ~/Desktop. This is detected as a Focused Window title change, so my Window Log macro is triggered. Great. However, If I navigate anywhere (for example by clicking on "Downloads" in the sidebar), the window title changes, but it is not detected by Keyboard Maestro. Odd.
Stranger still, if before I try to navigate, I switch application focus away from Finder and then back to it, everything works perfectly.
Using a third party app is not an ideal solution, though I thought it was worth mentioning that Default Folder X has an AppleScript command to return a list of the most recent folder. Can this maybe implemented for a snappier solution?
This is what Default Folder X developer had to say about this feature in his app:
I found another approach to all this on StackExchange. However, the stumbling block continues to be that navigating within an open Finder window doesn't register as a focused window title change, so regardless of the macro, nothing gets triggered. The window title is changing but isn't detected. The issue persists since I upgraded to Monterey, so it's not an OS version thing. Seems like some people aren't seeing that behaviour though, which only makes it more confounding.