CentOS 5.5: service not stopped on shutdown

I have wrote script /etc/init.d/xxx which start/stop my service on CentOS 5.5.

When I call 'service start xxx' or 'service stop xxx' everything works fine. But when I restart my machine, I see in the logs that on shutdown the service was not stopped.

However, it started on boot.

> chkconfig --list xxx 
 xxx  0:off   1:off   2:on    3:on    4:on    5:on    6:off

What I am doing wrong. Thank you.

UPD: the header of the script:

#!/bin/bash
#
# Startup script for the xxx
#
# chkconfig: 345 99 01
# description: This script ...
#

### BEGIN INIT INFO
# Provides: xxx
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start:
### END INIT INFO

I am not a linux guru, more of a noob actually, but in order to execute the shutdown script you must create a lock file in /var/lock/subsys/ folder in your startup script. I found the answer here: CentOS Forum

Script example:

#!/bin/sh
# chkconfig: 345 98 11
# description: my auto start-stop script.

echo "my service is doing something :)" >> /root/tempfile
case "$1" in
 start)
  echo "my service started" >> /root/tempfile
  touch /var/lock/subsys/myservice
  echo "OK"
  ;;
 stop)
  echo "my service stoped" >> /root/tempfile
  rm -f /var/lock/subsys/myservice
  echo "OK"
  ;;
esac

You might have to create a link in /etc/rc6.d/ directory, so that it will call that script when shutting down the server.

ls -l /etc/rc5.d/K60nfs

lrwxrwxrwx 1 root root 13 May 13 2010 /etc/rc5.d/K60nfs -> ../init.d/nfs