Lawsy posted a custom end gcode here last year. I've been using the same code minus one or two things.
http://www.soliforum.com/topic/231/impr … end-gcode/
I thing he uses a SD2 as do I, but I did not like the bed going all the way to the bed, so I adjusted the proper line in Slic3r to allow a 7mm clearance from my tools and clutter.
Save your start AND end gcode on a notepad file.
Copy and paste the given code.
Edit to your needs.
If it doesn't work out, copy then paste your original codes.
This is what I did. So since I do not know gcode like the back of my hand, I can only give you a personal empirical observation.
Hope this helps!
Printit Mason and Printit Horizon printers
Multiple SD2s- Bulldog XL, E3D v5/v6/Lite6, Volcano, Hobb Goblin, Titan, .9 motor, Lawsy carriages, direct Y drive, fishing line...the list goes on
Filawinder and Filastruder #1870.....worth every penny!