fixed some bugs

Fixed saving on exit and window closing and window show when deactivted