Closing the window with the X button will not close it immediately during the rendering of a frame, causing it to actually crash, but will set the engine in a pending state until it finishes the current frame.
Fixed issues when dragging the window, like the window stopping its movement when moving the cursor too fast, or flickering all over the place. Also, the window position will be clamped to the area of the monitor/s to prevent it from going outside of them.
Also, setting VSync instead of target FPS prevents possible stuttering and probably increased CPU usage.