Moved window delegate creation to createWindow.
Added window hiding before thrd_join.