Close session early on download stable5

This PR unblocks ajax calls when a file download is in progress. Currently, the php session is locked for the whole download. When the music app downloads a track in the background any other requests to the server are stalled.

Basically a partial backport of https://github.com/owncloud/core/pull/7651/files#diff-bf5278fcb7b34e55ed3153c34f7dfdf1R32

@DeepDiver1975 @karlitschek @MorrisJobke