I understand that apps on my iPhone can harvest my private usage data for things like advertising, selling my data, etc… Is that data only collected while actively using the app, or can it also be collected while the app remains closed and not in use?
An app can only do anything with the data you give it access to. It can’t collect new data while it’s closed.
If it’s running in the background it can collect data but only if you’ve given it permission. For example you might give an execrable app permission to record your heart rate, number of steps etc.