Bug fix: we can't draw on a window after closing
Refactoring