Added safety check to render texture and moved invalidation of frames before destroying the VPU handle