Hello,
If you suspect that the optimization process needs more time than allocated then I recommend increasing the value of that parameter. That will of course depend on the exact error that you are getting. Since there is no ST22 you might want to check SM21 or SM37 for more detailed errors.
On further consideration, if increasing the value of max_wprun_time does not adversely affect the processes running during business hours then you should increase it and evaluate if that resolves the issue.
Best Regards,
Leila