Fixed exception on window close.