system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: what is actually happening inside my computer when a program freezes?
gpt
Programs (under Windows anyway) are given a continuous stream of messages by the operating system. These messages include notifying the program when the user tries to close it, or when the window is interacted with in other ways. If the program is written badly, it may not acknowledge these messages. Windows detects that the messages are not being acknowledged, and marks the window as "Not Responding", as you may have seen.

As for why programs freeze in the first place, the program may be too busy to acknowledge the message right away, but given enough time it may catch up; or the program may be locked up completely and will never catch up. These are called infinite loops, because they will never end.