Koen, I am on Moodle 3.5+ (Build: 20180607) and this has been happening to me for two years on each and every version, finally I have it resolved, I verified the grades (truthfully unworried as I had reset all my classes for the year) and the bulk cleanup went through after experiencing the error repeatedly both in bulk and individual user deletion.
I appreciate your time posting the steps/solution.
May you have a great summer!