fixed seg fault on window.close