Fix memory leaks related to the debug window.