added exit and close media