Release resources in finalize before releasing parent class

Change-Id: I9c8317e3a81c4eef6a9fadb11cae4e9fd1b09b53