bash interprets the # as a comment marker, so it and everything after it is ignored. I think the suggested paste should look like this:

cat > $HOME/.kde/env/start-custom.sh < $HOME/.kde/shutdown/stop-custom.sh << EOF
#!/bin/sh
if [-n "$GNOME_KEYRING_PID"]; then
kill $GNOME_KEYRING_PID
fi
EOF
chmod 755 $HOME/.kde/shutdown/stop-custom.sh

Which works for me, creating two sane shell scripts in the appropriate locations.