moved php shutdown function into error handler
removed gc cycle code
improved shutdown/quit code