I believe this function is called "resource tracking" and it's to be integrated in OS4.
From the feature list:
"Resource tracking: Applications can create "trackable" resources, for example memory, message ports, messages, semaphores, and have them tracked by ExecSG. When the program exits (either normally or abnormally due to a crash) the resources are freed automatically."