There are no exit formalities in the US (ie, no exit immigration). Therefore, your only requirement is that you are able to physically make it to the other terminal within the stipulated time.
In the old days, you used to have a paper I-94 form, but even this information is now digitized so that's another thing you don't have to worry about.
I am not familiar with EWR enough (I last flew a transit through EWR 10 years ago), but what I do know is that if an airline has booked you a ticket, they are required to give you enough of a transit time to make your other flight.
In other words, United is telling you that 51 minutes is enough time for you to get from one flight to the other.