You can write a destructor function for your class to release resource using __destruct() method.