Save the settings no matter how the application is closed.
(cherry picked from commit 87ad7f2ec66d79b29fe7b081ff7e629950062480)