Quote:
how that I make my program generate a ini file after I exit it.
Short answer: you don't.
Programs never do something after exit.
Generally speaking, for any interactive program, the program is "do something" on event or user choice.
In your case, rather than just "exit" on request, the program is "do something (write the ini file) and then exit"