Is it good UX to prompt users before closing the browser window on mobile

i'm designing a mobile web based e-commerce solution. If the user closes the browser window, items in their cart will be lost (assuming they rejected the initial cookie request) when they return. To prevent this i'm considering prompting the user if they are sure they want to close the browser and would like to create an account . Is this a good way to overcome this issue or is there another way?