Triac BTA316 does not turn off
Test whether the triac is OK by leaving its gate floating. It shouldn't conduct. 

You can put the control signal to high impedance state, this should kill the triac at the end of the period.

OT: be very careful if you really must have the power supply referenced to the line (as is on the picture).

Edit: the schematic is not wrong as others claim - it is possible to use line as reference, but one has to keep in mind that the moment the GND connects to neutral you got a short circuit. And it is all too easy to happen in this setup. For example, if you connect to grounded lab instrument (oscilloscope) you get a short. I've been using similar setup in a project that measured noise on the power lines. There you need it if you have non-isolated supply. I knew the risks, but I still managed to burn the prototype, the programmer and my computer. Also, don't let me start on the fireworks it caused..