Sanderling.MouseClickLeft(Measurement?.WindowStation?.FirstOrDefault()?.UndockButton);
does not find the undock button
I am using this rather clumsy workarround:
Options → Shortcuts → General, find Exit Station in the list, assign a hotkey
Undock by sending a Hotkey with:
Sanderling.KeyboardPressCombined(new[]{VirtualKeyCode.LMENU, VirtualKeyCode.VK_D});
I am using ALT-D in this example