When testing, we need to query the state of the Qt application,
so change the scope of qtloader from inside the init function
to global scope.
Additionally, adjust the test script accordingly to query and use this
state to make good decisions on how to terminate.
Change-Id: I6264ba20843716eb87340b160680617b718f6bd9
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>