Concept Flow - Defer statement for cleanup
Start function
Execute code before defer
Register defer block
Continue function execution
Function about to exit
Run defer block(s) in reverse order
Function ends
The defer statement registers code to run later, just before the function exits, ensuring cleanup happens even if errors occur.