When you click inside the window and you are not defining any state condition when the event happens it may hang.
So add this condition anywhere:
for event in pygame.event.get():
if event.type == MOUSEBUTTONUP:
None
This would tell it when you click the mouse do nothing so it will not hang.
That worked for me.