Added checks for shells to close in PreferencePage ok and cancel method. Fixes #639