You have to interact with the possessed pokemon to free it, causing the ghost type to return back to your party
Thank you, I thought I checked for this, but I guess not.