Make use of Ruby's at_exit

Use at_exit to close the font and the input file