why my script in /etc/init.d with K symbolic link in rc0.d and rc6.d and S symbolic link in rc5.d is not working on shutdown?

I’m writing a script which I want to run before every shutdown of my ubuntu system. I have placed my script named myscript inside /etc/init.d folder and then created symbolic links in rc0.d and rc6.d as K01myscript and S01myscript in rc5.d. But the problem is that the script is not running at all.