Run function written in renderer code file on main thread


I have a function that gets loaded on the renderer thread and I need to execute it on the main thread so it still runs if all windows close but the app is still alive.
Do you guys have any idea how I could accomplish this? I saw that you can’t pass function as arguments to the ipcRenderer and ipcMain.