C++11

Reference #1401.

Change much stuff to use new library.
It seems that without this check all sources (logoff, shutdown, etc.) that can cause a close are handled, as opposed to just the red crossed button.