The GFCI outlet in my bathroom pops when I turn off the bathroom fan
It's not the outlet.  It's a ground fault.

Here's what is happening.  When you have a big magnetic coil, and power is flowing through it, it makes a magnetic field.   When you suddenly interrupt that power, the magnetic field collapses, and this has a small force behind it. It is the nature of coils to resist changes in current flow.  It does this by turning that small force into voltage, which increases until the desired current flows, or the force just runs out of energy.  This is called an "inductive kick" and everything in the circuit must be insulated for it. 

When the insulation fails, the high voltage will ignite an arc that the lower voltage will sustain.  It can also leap across switches!   In DC power over about 30 volts, this arc is Very Nasty Business because the arc will never stop. 

However, with AC power, AC switches polarity 100-120 times a second (8-10 milliseconds).  It is a sinewave, and part of the time it is near zero volts.  The arc will self-extinguish at the next zero crossing.  But in the meantime, the arc will flow enough current (potentially a lot of current) to trip the GFCI.  

However... If you happen throw the switch at the right instant, you are near a zero-crossing for the voltage or magnetic field, so there's no magnetic field and no inductive kick.  So no voltage spike. 

So, no leakage and no GFCI trip.  

Insulation is failing.  This will get worse.  

I would start by changing the switch because they are cheap.  But prepare for a fan replacement, or at least take it down and clean it.  Damp dust makes a great leakage path. 

Note that switches have ratings, and their rating for a motor (inductive) load is much lower than a plain load.   They may also have a similar "ballast" rating, because HID and older fluorescent lights have ballasts with a big inductive winding.  Their tungsten rating has nothing to do with this.