I'll assume that you are using the jamfHelper app to lock the screen. You have to make sure you put the process in the background for the rest of the script to run. You'll need a line like this:
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType fs -icon "$iconpath$icon" -heading "$heading" -description "$description" &
#### Now Do your special scripty stuff
#### Now unlock the screen
killall jamfHelper
The ampersand (&) at the end of the jamfHelper line puts the process in the background and allows the script to continue running. Otherwise the script pauses and waits for the completion.
So I would also need to create a method for it to check to end on?
Essentially what were trying to do is allow a device to enroll from the website. Once the package is installed it checks for policies and that's when this policy is run.
I want to lock the screen, then image the machine like normal. Once it's done installing the files it'll reboot. So should I still have a check for ending or will it end ok on the reboot?
If that's all you are doing, and you are not worried about unlocking the screen for the user at the end of the installation, you do not need the "killall", the reboot will take care of that.
It might not work just to have the Mac reboot, although it would depend on exactly how you're initiating the reboot. Still, if it were me I would have it check for something that indicates the rest of the script is complete. That could be something as simple as checking that the last process' exit status is successful, such as:
if [ $? == 0 ]; then
## Now, kill jamfHelper (alternate method from what Steve shows above)
/bin/ps axc | awk '/jamfHelper/{ print $1 }' | xargs kill -9
/sbin/shutdown -r now
fi