Adding php shutdown function, fixes #4