fix for Error on program close