Added in window size saving and safe database closing.