code: def gameloop(self):
          
          try:
              while True:
                  for event in pygame.event.get():
                      if event.type == pygame.QUIT:
                          sys.exit()
                      if event.type == pygame.KEYDOWN:
                          if event.key == pygame.K_ESCAPE:
                              pygame.event.post(pygame.event.Event(pygame.QUIT))
  
                  self.recv_data()
                  self.update()
                  self.render()
          except KeyboardInterrupt:
              pass
docs: Loop through all the necessary stuff and end execution when Ctrl+C was hit.