Fix closing of media