Modified Exit-Script function to log any error that may have been passed to it.