Functions registered with atexit are called from the thread calling exit. glfwTerminate should only be called from the main thread. Mistakes should be explicit.