XQuartz right away quits itself
I was able to solve it by running from the Terminal.
run_Xquartz() {
  [ $(ps aux | grep -E '[X]quartz' | wc -l) -gt 0 ] &amp;&amp; echo 'Xquartz is already running' \
  || nohup /Applications/Utilities/XQuartz.app/Contents/MacOS/X11.bin &gt; /dev/null 2&gt;&amp;1 &amp;
}

$ run_Xquartz


If Xquartz is already running on the background it prints Xquartz is already running.
If Xquartz is not running on the background it runs it on the background using nohup.

=&gt; When Xquartz starts running on the dock you will see it.