fixed issue with c-program not closing directly