Remove unused function and properly close windows with frame code exceptions.