fix bug with destroy window