Fix for properly closing open fd on error.
Fix for properly closing open fd on error.

dicej/icewm,dicej/icewm,dicej/icewm,jinn-alt/icewm,jinn-alt/icewm,bedna-KU/icewm,dicej/icewm,jinn-alt/icewm,bedna-KU/icewm,bedna-KU/icewm