Simple... the files are parsed top to bottom... place the scrips in needed INCLUDE files and call them where needed with the include function.
The unload script is a bit of a burdon, so I recommend you just make an intermediate routing file (if it involves sending headers) or jsut place it at the bottom of the file (if it doenst involde headers).
For example I like to keep my code separate, and to send an email from a form will do this:
sendfolr.hmtl --> POST data to --> sendit.php --> Header("Location: done.html") -->
done.html --> or, if mail fails go to some file where it says fail... 🙂)