Fixed application not closing properly

Also fixed the video input not being closed, which was causing a
application slowdown, due to high processing.