Fix ris contexts

The issue in 8628536ad2f19c860aadf02da9cb1d2ffe61bc46 was that code did not execute after the following line:

    OutputStream aOutputStream = response.getOutputStream();

So in this changeset, the context is closed before writing the stream