Render movies using sequencer with python script

I am working on a script for rendering multiple sequences one after another. When I used unreal.SequencerTools.render_movie it is performing the tasks asynchronously causing the editor to crash by starting a second render job without completing the first one. How can I modify the render_movie to render sequences synchronously?

Error message:
LogPython: Error: unreal.SequencerTools.render_movie(capture_settings, on_finished_callback)
LogPython: Error: RuntimeError: SequencerTools: Capture already in progress.

Any help would be appreciated.