Each time Linux starts up, it runs one process: init. That process refers to /etc/inittab to tell it what to do for the current "runlevel," normally "5." (See man init, et al.)
And that usually consists of an instruction to run all of the "Snn.." files found in /etc/rc.d/rcn.d, where "n"=the current runlevel. (On boot, it runs "sysinit" first.) It runs the files in ascending order: hence the two-digit numbers in the names, used to enforce the order. You'll notice that each one of these files is a symlink, or alias, to files in /etc/init.d. (Whew!)
The "K..." files are used to close things down when switching runlevels: "K" is for "Kill." (So saith the author Sue Grafton.)
So, that's the mechanism that you will use.