Looking at the line:
aline line 0, 1, 1024
After 1 second aline is 1024, but if the note extends beyond 1 second line will continue in the direction in which it is going. After 2 seconds aline will be 2048 and so on.
If you swap the line opcode for linseg, linseg will hold its final value rather than continue.
Also the table pointer should go as far as 1023 not 1024; 0 is the 1st table value, 1023 is the 1024th table value
so "aline linseg 0, 1, 1023" should fix it.