Prevent parting when clicking close button on main window.

issue #21 and very many mentioned here and there