One step forward: what described in my previous post happens when the window that I open from win_1 (say win_2) displays a gif picture. In this case, I can close win_2, but when I then close win_1 I get the error.
I use the following code to display a picture:
allocate (iray(imgdim))
allocate (cray(2*imgdim))
picture(1:) = trim(path)//'/img/sigma.gif'
call LDIMG(trim(picture),iray,imgdim,-1,N)
cray = transfer(iray,cray)
call SWGPOS(160,SEP*iw+10)
call SWGSIZ(imgw+6,imgh+6)
call WGIMG(ipmat,' ',cray,imgw,imgh,id_pic1)
deallocate (iray)
deallocate (cray)
If I comment this lines I do not get the error.