Deployment killing instance still running task

Hello,

I have a python FastApi dockerized app that has 2 instances. At some point, it starts some background tasks that take quite a bit of time.
If during the execution of the said background task, there is a deployment happening, the instance gets killed and a new one is spawned.

We’re using
flyctl deploy -a <app-name> --strategy bluegreen --remote-only --config fly.toml

How can we deploy without killing the said instance with the running task?