2 bugs left: (1) calling foreground after background waits for background to finish too (2) exit()