Suggestion: Check for $USER4 being zero and if zero then it is the first call so you GETMAIN storage and save the address of the storage in the $USER4 field for the next time the exit is called. You could replace this:
XC 0(length,R5),0(R5) Clear to binary zeros
ST R5,$USER4 Save for future calls
GOODU4 DS 0H
Note: This code has NOT been tested. It is sample code only.
I would also suggest adding an eyecatcher at the beginning of the USER4WS to aid in problem diagnostics, for example:
U4EYE DS CL8'USR4XEXE' Eyecatcher for dumps
And add code to set this field like: "MVC U4EYE,=CL8'USR4XEXE'