With the last OpenCV versions ( i suppose after 4.4 ) destroyWindow terminates the application when the window with that name is not existing or just closed.
Using earlier OpenCV versions destroyWindow doesn’t give any error.
the application is terminated and the following error is given:
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.5.3) Error: Null pointer (NULL window: ‘asdf’) in cvDestroyWindow, file D:\3rdParty\OpenCV\opencv-4.5.3\modules\highgui\src\window_w32.cpp, line 1246