Remember window size.

Refs #154
Refactor saving of window geometry.

Closes #154
Rename settings key for window geometry.
Only save geometry when close event is accepted.
Merge with upstream