Fixes #218 @adrian17 did all the work for this fix.

Fixes the annoying issue where the graphics mess up when you try close the game with the options window open. Issue was caused by writing to unallocated memory due to a mistake i made back in #117.