Fixes #318 hopefully, no longer should crash after closing windows.