This is what you do: you approximate the actual power pulse with a rectangular pulse having the same amplitude as your actual pulse and a width (length) such that the area is equal to that of the original pulse.
For your exponential pulse, the equivalent rectangular power pulse will have the peak equal to Uc^2/R and the duration equal to half the time constant. t=(R*C)/2. (You can do the integration of power from zero to infinity, to verify the validity of the above). This approach ensures that the peak pulse power is equal to the actual peak power, otherwise, as you observed, the power may appear to be OK, if integrated over a longer period of time.
Then you check the datasheet and there should be some curves that indicate the maximum pulse power capability of your particular resistor, for various pulse durations. Enter the duration calculated above (half the time constant) and check if the power handling capability is higher than the actual peak power applied.
Make sure you use the curve that is relevant to the ambient temperature and continuous power dissipation before pulse application. Obviously, if the resistor is dissipating some significant power (its rated power) before the pulse is applied, its pulse capability is lower.
If you cannot find those curves, contact the manufacturer.
As an example of curves, see this part of a Vishay datasheet for surface mounted resistors.
My guess is that your 5W resistor will NOT take the 4kW for 0.88 ms (although I do not know what type it is). You can connect more resistors in series/ parallel until you reach the required pulse power capability.