Crash in example code at function call gym.draw_viewer(viewer, sim, True)

My computer crashes on running the example codes in the Isaac Gym folder. Immediately after running any example script that involves a GUI window of the simulation, all the screens black out and I am shown a log-in screen for my user account on Linux.

For example on the script, commenting out the line gym.draw_viewer(viewer, sim, True) prevents this crash from occurring.

Similarly, the environments such as AnymalTerrain from IsaacGymEnvs work only when headless mode is set to True in the config files. It will crash when the headless mode is set to False.

Kindly help. This has been happening with my computer with the previous installations as well. Please let me know if I can provide any further information