Running the query in the background causes JMP to not wait for the results before moving on to the next command, so you have to tell it to wait. I generally define dt as Empty() before the query and then tell JMP to wait until dt is scriptable before moving on.
dt = Empty();
query = New SQL Query(
Connection(""),
QueryName(""),
Select(Column("", "t1"), ),
From(Table("", Schema(""), Alias("t1")), )
);
query << Run Background(OnRunComplete(dt = queryResult));
While( !Is Scriptable( dt ), Wait( 1 ) );
project = New Project();
project << Save As("");