It sounds like you have started this from a web browser and (as you said) the connection has timed out.
One approach you could take is to move most of the processing to a queue so it runs in the background and is no longer dependent on the frontend.
I see you are running Mendix 7, so you’d have to look at the Queue or ProcessQueue module. However, this is deprecated because Mendix 9 has this functionality built in with the Task Queue.
I would suggest upgrading your application to Mendix 9 and using Task Queue. If you do, it is essentially as simple as breaking out most of your functionality into a submicroflow and calling this while ticking the run in task queue option.
You can find out more on the Task Queue on this page of the documentation.
https://docs.mendix.com/refguide/task-queue/
Hope this helps.