Hi,
I had the same problem.
I noticed that in the code that was generated by Cura, there was a 5 mm retraction before the end code was executed. For me, this 5 mm retraction was enough, so I decided to delete line 3 and the E-5 code in line 4.
Now at the end of the print, the filament is retracted 5 mm (generated by Cura) and then the end code is executed and the nozzle moves to the side of the print.
I'm not sure why the problem is happening with the original code, but the solution works fine for me.