Corrected segfault on window close which was caused by a double free