Added window counting and proper initialization and termination of GLFW.