Well, double check at closing!
My problem was, the file was still open (I don't remember why) and if I restarted map (ONLY THEN) I had this error.
So double check also use if(fid == -1).