It can surge, principally due to the "dynamic part" of the problem.
If the volume at the discharge of the compressor is relatively important, it takes a while to get rid of the pressure downstream.
Opening the anti-surge valve fully may be insufficient in some cases. While the compressor descellerate, there may be enough energy downstream to cause flow reversal/surge. A hot gas by-pass is generally designed / prescribed for that specific purpose, that is to relieve the system pressure much quicker thereby maintaining the compression path (during ramp down) at safe distance from surge line.
Moreover if the driver, for example a turbine, does not permit to reach a stop / stand still in a short while and compressor effectively undergoes surge during shutdown, that surge phenomenon cannot be considered limited anymore which includes potential consequences on machinery (damages).