How do I deselect an active cell when clicking on an image to run a script?

I have a spreadsheet-bound script that is invoked by clicking an image in the spreadsheet. I've found that the script can be blocked if a cell that it needs to modify is active or being edited by the user. The code could be anything, even as something as simple as this:

function newf()

When the cell R4 is open, the function will ignore the cell. How do I deselect an open cell when clicking on an image to run a script? The easy (manual) solution would be to click off the open cell prior to clicking on the image, but I am trying to make the script fool-proof and this can be a costly concern. Is there any way that the function can forcefully deselect an active cell? Edit: I do not mean active cell. Definitely "open cell." Here are pictures of the error. Open cell with data being entered
Open cell with data being enteredClicked on Picture, program ran
Clicked on Picture, program ran