Fix latent refcounting error in the PSGI plugin

Can be reproduced under the Perl debugger, see the commit message for a full explanation.