Running code when the program closes

Hello!

I’ve got some UDP code, and I would like to run closesocket() when my program exits. Is there some sort of event or class that I could use to run this command on exit?

Thanks,
Alek

Override Shutdown() function in a custom GameInstance class:

Thank you!