Websocket: Add session locking and delay close

This resolves a race condition where data could be written to a NULL
FILE pointer causing a crash as a websocket connection was in the
process of shutting down by adding locking to websocket session writes
and by deferring session teardown until session destruction.

(closes issue ASTERISK-23605)
Review: https://reviewboard.asterisk.org/r/3481/
Reported by: Matt Jordan


git-svn-id: http://svn.asterisk.org/svn/asterisk/branches/11@413123 f38db490-d61c-443f-a65b-d21fe96a405b