Close button in barcode scanner

Hi, i am trying to make a simple bar code scanner app, everything works fine but i need a close or back button on to the camera view, could someone help me
I tried something like this but this dose’nt work well as the app gets restarted again on pressing back button

this.platform.registerBackButtonAction(() => {
console.log(“backPressed 1”);
(window.document.querySelector(‘ion-app’) as HTMLElement).classList.remove(‘cameraView’);