Move wm_close handling to a shared library
Move stdout/err disabling to a library class