[macOS] Unity freezes and never exits when running Test Runner from Command Line

To reproduce:
1. Open Terminal window
2. Download user's project and unzip it
3. Launch Test Runner by using this command:
/(path to the folder with Unity's installation)/Unity.app/Contents/MacOS/Unity -projectPath (path to the folder with user's project) -batchmode -runTests -testPlatform editmode -logFile (enter path where log file should be saved)

Expected result: After running a test Unity should close itself (terminate).
Actual result: Unity freezes and you have to Force Quit it.

This issue is not reproducible with Unity 5.6.3f1 so my projects are currently stuck on that version as upgrading means that all continuous integration tests fail (due to timeout). Also, as a Unity upgrade of the projects is required to work with macOS High Sierra, this issue is also currently blocking an OS upgrade.