You can add start and end scripts to your printer by creating G-code.
This page gives you the The 10 most common G-code commands for 3-D prinitng
You can also research G-codes on the RepRap Wiki
This has some cool end code snippets
And this Cheat Sheet from Thingiverse is cool.
I added this right before the;
M84; Stop the Stepper Motors
Command.