fix osx window closing crash, fix rendering bug